题解 | #单词倒排#
单词倒排
http://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836
随便写的,比不上各位大牛,适合初学
i=0
list1=[]
while i <len(s):
j=0
if (s[i]>='a' and s[i] <='z') or (s[i]>='A' and s[i] <='Z'):
temp=s[i]
j=i+1
while j<len(s) and ((s[j]>='a' and s[j] <='z') or (s[j]>='A' and s[j] <='Z')):
temp+=s[j]
j=j+1
# print(temp)
list1.append(temp)
i=j
else:
i=i+1
# print(list1)
list1.reverse()
print(' '.join(list1))