题解 | #单词倒排#
单词倒排
https://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836?tpId=37&tqId=38366&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=
str=input() ls=list(str) index=len(str)-1 while index >= 0: f=97<=ord(ls[index])<=122 or 65<=ord(ls[index])<=90 if f==False: ls[index]=' ' if ls[index]==' 'and ls[index-1]==' ': del ls[index] index-=1 a=''.join(ls) ls_2=a.split(' ') ls_2=ls_2[::-1] for item in ls_2: print(item,end=' ')