1class Solution:2def reverseWords(self, s: str) -> str:3s = s + " "4l = len(s)5t = ""6w = ""7for i in range(l):8if s[i] != " ":9t = s[i] + t # t stores the word in reverse order10else:11# w stores the reversed word in the same order12w = (13w + t + " "14) # could have used .join() function and not write .strip()15t = "" # value of t is null so that it won't affect upcoming words16return w.strip() # removes extra whitespace