CODING PRACTICE - 20 Reverse the Letters in Words of the Sentence
Reverse the Letters in Words of the Sentence
Given a sentence, write a program to reverse the letters in words of the sentence.
Input
The first line of input will contain a string.
Output
The output should be a single line containing the sentence by reversing all the letters in words.
Note: The order of the words in the modified sentence should be the same as in the given sentence.
Explanation
For example, if the given sentence is the following.
Print the sentence by reversing the letters in words without changing the order of the words in the sentence. So the output should be
Input
The first line of input will contain a string.
Output
The output should be a single line containing the sentence by reversing all the letters in words.
Note: The order of the words in the modified sentence should be the same as in the given sentence.
Explanation
For example, if the given sentence is the following.
The cat is on the mat.
Print the sentence by reversing the letters in words without changing the order of the words in the sentence. So the output should be
ehT tac si no eht .tam
Sample Input 1Sample Output 1
The cat is on the mat.
ehT tac si no eht .tam
Sample Input 2Sample Output 2
Have a nice weekend.
evaH a ecin .dnekeew
code:
se= input() wl= se.split() ms=[] for word in wl: ms+=[word[::-1]] rls = " ".join(ms) print(rls)
Comments
Post a Comment