Answer to Question #263333 in Python for anji

Question #263333

Reverse the sentence


your are given a string S as input , write a program to print the string after reversing words of the given sentence.


the first line of input is S.


in the given example the sentence "This is Python" contain 3 words ,when reversing the word "Python" comes to the starting of the sentence and "This" goes to the last of the sentence ,the word "is" remains in the same position.


so the output should be Python is This.



SAMPLE INPUT 1

This is Python

OUTPUT :- Python is This

SAMPLE INPUT 2

Hi! World Hello

OUTPUT:- Hello World Hi!



1
Expert's answer
2021-11-09T04:29:30-0500
input_string = input()
string_split = input_string.split(" ")
string_split.reverse()
print(" ".join(string_split))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS