题解 | 单词倒排

单词倒排

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

import sys
import re

sentence = input()  
sentence = re.split(r'\W+', sentence)   # 以非字母分割字符串
sentence = ' '.join(reversed(sentence)) 

for i in sentence:
    if ord(i) < 65 or (90 < ord(i) < 97) or ord(i) > 122:  #既不是大写字母也不是小写字母
        sentence = sentence.replace(i, " ")

print(sentence)


全部评论

相关推荐

双尔:你就写拥有ai开发经历,熟练运用提示词,优化ai,提高ai回答质量
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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