我的“输出”似乎填充正常但是当我执行连接时,我得到“没有返回。
有什么想法吗?
def englishify_sentence(s):
"""English"""
words = s.lower()
words = words.split()# splits sentence into individual words
output = []
for i in range(len(words)):
if words[i].endswith("way"):
opt1 = words[i][:-3]
letters = list(opt1)#breaks given word into individual letters
translate = ("("+opt1+" or "+"w"+opt1+")")
output.append(translate)
else:
opt2 = words[i][:-2]
opt2_letters = list(opt2)#breaks given word into individual letters
first_letter = (opt2_letters.pop(-1))
opt3 = words[i][:-3]
translate2 = (first_letter+opt3)
output.append(translate2)
english = " ".join(output)#removes speech marks and creates a "real" word
print(output)
english = englishify_sentence("oday ouyay antway anway eggway")
print(english)
答案 0 :(得分:2)
您忘记返回该值。
return english
答案 1 :(得分:0)
是否打印(输出)给你一个无或打印(英文)?