Reverse words in a string 2
Problem to reverse the each and every word in a string.
Example-1:
Input : s = "hello world" Output : olleh dlrow
Example-2:
Input : s = "i love myself" Output : i evol flesym
Solution
s = "hello world" a = s.split() d = "" for i in range(len(a)): d += a[i][::-1] d += " " print(d[:-1])
Output
olleh dlrow