题解 | #单词倒排#
https://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836
st = input() lis = list(st) a = [] b = [] for i in lis:#把非字母变成空格 if i.isalpha(): a.append(i) else: i = ' ' a.append(i) s = ''.join(a).split(' ')#根据空格进行分割存储到列表 tmp = s[::-1]#列表倒序 for i in tmp:#去除空格元素 if i != '': b.append(i) print(' '.join(b))