In this program, we will take a string as input and reverse words in a string
Steps to solve the program
- Take a string as input.
- First split the string using split() and then reverse the words using reversed().
- Print the output.
#Input string
str1 = "string problems"
#Input strinh
print(" ".join(reversed(str1.split(" "))))
Output :
problems string