题解 | #单词倒排#
单词倒排
http://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836
words = input()
for letter in words:
if not letter.isalpha(): # 判断非字母
words = words.replace(letter, " ") # 使用间隔(空格)替换
new_words = (words.split())[::-1] # 切片字符串返回列表,使用倒序
for i in new_words:
print(i, end=" ") # 输出,使用空格间隔