题解 | #单词倒排#

单词倒排

https://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836

'''
from re import L
l=list('I am a student'.split())
l1=reversed(l)
print(l,l1)
#print(ord('a'),ord('z'),ord('A'),ord('Z'))
'''
'''
while True:
    try:
        sentence=input()
        for i in sentence:
            if 65<=ord(i)<=90 or 97<=ord(i)<=122:
                sentence
            else:
                sentence=sentence.replace(i,' ')   # for循环中,a=a.replace(),不能只写a.replace()
        #print(sentence)
        sen_list=list(sentence.split())
        sen_list.reverse()                         # list.reverse()原地逆序
        print(' '.join(sen_list))
    except:
        break
'''

while True:
    try:
        sentence=input()
        for i in sentence:
            if 65<=ord(i)<=90 or 97<=ord(i)<=122:
                sentence
            else:
                sentence=sentence.replace(i,' ')
        #print(sentence)
        #print(sentence[::-1])
        sentence1=sentence.split()
        print(*sentence1[::-1])    # *[list] 列表解包;[::-1]逆序
    except:
        break



全部评论

相关推荐

qz鹿:*** 祝他毕业就失业
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
10-05 10:13
已编辑
HHHHaos:让这些老登来现在秋招一下,简历都过不去
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务