def cat_latin_word(text):
""" convert the string in another form
"""
constant = "bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ"
for word in text.split():
if word[0] in constant:
word = (str(word)[-1:] + str(word)[:4] + "eeoow")
else:
word = (str(word) + "eeoow")
print(word)
def main():
""" converts"""
text = input("Enter a sentence ")
cat_latin_word(text)
main()
您可以使用列表来放置所有单词,或者以不同的方式使用print()。
示例:
这里我使用关键字参数
end
将其设置为'\t'
(默认为'\n'
)几点提示:
string
模块,并使用set
来实现O(1)查找复杂性。你知道吗str
。你知道吗' '.join
结合使用。你知道吗下面是一个工作示例:
只需编辑代码,就可以将结果作为空格分隔的单词返回。你知道吗
相关问题 更多 >
编程相关推荐