题目
15.编写程序,将用户输入的英文语句中的单词(忽略标点符号)进行逆序排列后输出。
例如:用户输入"How are you",则程序输出"you are How"。
参考代码
a = input("请输入一句英文语句:")
lst = []
for i in a.split():
lst.insert(0,i)
lst_1=' '.join(str(i) for i in lst)
print(lst)
运行结果
请输入一句英文语句:How are you
you are How
说明
此方法仅供学习参考,欢迎讨论