题解 | #单词倒排#
单词倒排
https://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836
arr = list(input()) # 将所有非字母替换成空格 for i, ch in enumerate(arr): if not ch.isalpha(): arr[i] = " " # 从列表变成一个字符串 string = "".join(arr) words = string.split(" ") for word in words[::-1]: if word != "": print(word, end=" ")