class Solution(object): def reverseWords(self, s): """ :type s: str :rtype: str """ return ' '.join([sub_s for sub_s in s.split(' ')[::-1] if sub_s])