句子逆序list.reverse() .join()/for

句子逆序

https://www.nowcoder.com/practice/48b3cb4e3c694d9da5526e6255bb73c3

while True:
    try:
        words=list((input().split(' ')))
        #print(type(words),words)
        words.reverse()
        #print(words)
        for word in words:
            print(word,end=' ')
        print()
        #print(' '.join(words)) 直接用join()更简洁
    except:
        break


全部评论

相关推荐

不愿透露姓名的神秘牛友
07-07 13:15
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-04 14:23
steelhead:你回的有问题,让人感觉你就是来学习的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务