编写一个python程序 编写一个程序,将用户输入的英文短句中每个单词在句子中的位置进行反转后输出(单词间均以空格分隔,不必考虑标点符号问题)。示例输入 : nothing gold can stay 示例输出: stay can gold nothing
sentence = input("请输入一个英文短句:") words = sentence.split() reversed_words = words[::-1] reversed_sentence = " ".join(reversed_words) print(reversed_sentence)
原文地址: https://www.cveoy.top/t/topic/tzh 著作权归作者所有。请勿转载和采集!