题解 | #单词倒排#
单词倒排
http://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836
#把字母的单词找到,再用空格连接,逆序输出 # import sys while True: try: s = input() words = [] word = '' for c in s: if c.isalpha(): word += c else: if word != '': words.append(word) word = '' if word != '': words.append(word) word = '' print(' '.join(words[::-1])) except: # print(sys.exc_info()) break