python实现输入一段英文单词后,倒叙输出
作者:互联网
实例:实现输入一句英文后,单词倒序输出,eg:输入“I am a student.”,输出“student. a am I”!
自己面试的时候一道题,这么简单,我竟然不会写,哎!!!算是个教训吧!
def reverse_sentence(sentence): words=sentence.split() words.reverse() new_str=" ".join(words) return new_str s="I am a student." print(reverse_sentence(s))
标签:student,sentence,python,am,倒叙,英文单词,words,new,reverse 来源: https://www.cnblogs.com/pythonbigdata/p/12342784.html