字符串相关题目
1.说反话:给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 # 说反话 2 # 方法1 3 str1 = input() 4 lst1 = str1.split(" ") 5 lst1.reverse() 6 s = " ".join(lst1) 7 print(s) 8 9 # 方法2 10 str1 = input() 11 lst = str1.split(" ") 12 lst.reverse() 13 for i in range(len(lst) - 1): 14 print(lst[i], end=" ") 15 print(lst[len(lst) - 1])