Leetcode_Python 151  翻转字符串里的单词_leetcode

解题思路

此题思路与557题一致

代码

class Solution(object):
    def reverseWords(self, s):
        """
        :type s: str
        :rtype: str
        """
        s = s.split()
        b = s[::-1]
        a = ""
        for i,num in enumerate(b):
            if i == 0:
                a = num            
            else:
                a += " " + num
        return a