因为我只是一个初学者,所以我在Python 3.5中创建了一个小型单字猪拉丁语翻译器。我有我的粗略代码,但我真的很喜欢你的意见,如何使它更紧凑,pythonic,和“优雅”(即专业)。任何帮助表示赞赏,谢谢!在Python中“清理”基本猪拉丁语翻译器
#Converts a word into pig latin, needs to be cleaned up
def pig_latin(word):
word = list(word)
first_letter = word[0]
del word[0]
word.insert(len(word),first_letter)
word.insert(len(word),'ay')
print(''.join(word))
那么对于初学者'x.insert(LEN(X)中,y)'相当于'x.append(Y)'。 –
添加文档字符串,以描述输入和预期输出。 –
由于你有工作代码,这可能更适合于[代码评论](http://codereview.stackexchange.com/) –