照着Codecademy的在线指导,谢了Pyglatin的小游戏(字符转换)代码如下:
pyg = 'ay'
original = raw_input('Enter a word:')
if len(original) > 0 and original.isalpha():
word=original.lower()
first=word[0]
new_word=word[1:len(word)]+word[0]+pyg
print "Original is %s"%original
print "Translated: %s"%new_word
else:
print 'empty'