题解 | #单词倒排#
单词倒排
https://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836
stri = list(input()) for i in range(len(stri)): if stri[i].isalpha(): pass else: stri[i] = ' ' str2 = ''.join(stri) strlist = str2.split() strlist.reverse() # reverse()的返回值是None, 功能是改变原列表,字符串元组没有这个函数,可以先转换成lsit再操作 print(' '.join(strlist))