题解 | #单词倒排#
单词倒排
https://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836
先将非字母字符都替换成空格,再以空格分词得到单词列表,最后对单词列表逆置,以空格连接打印
while 1: try: raw = input() for r in raw: if not r.isalpha(): raw = raw.replace(r, ' ') res = raw.split() res.reverse() print(' '.join(res)) except: break