实例:实现输入一句英文后,单词倒序输出,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))

 

相关文章:

  • 2021-07-10
  • 2021-06-04
  • 2022-12-23
  • 2021-05-02
  • 2022-12-23
  • 2021-06-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-19
  • 2022-02-02
  • 2022-02-01
  • 2022-12-23
  • 2022-12-23
  • 2022-01-28
  • 2022-12-23
相关资源
相似解决方案