Reverse words in a string



Problem to reverse the sentence.



Example-1:


Input    : s = "Welcome to Mycrazycoding Website"
Output   : "Website Mycrazycoding to Welcome"


Example-2:


Input    : s = "she is beautiful"
Output   : "beautiful is she"  







Solution





s = "Welcome to Mycrazycoding Website"

a = s.split()

b = a[::-1]

l = []

d = ""

for i in range(len(b)):

    d += b[i]

    d += " "

print(d[:-1])



Output



Website Mycrazycoding to Welcome