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.
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 1
The cat is on the mat.
Sample Output 1
ehT tac si no eht .tam
Sample Input 2
Have a nice weekend.
Sample Output 2
evaH a ecin .dnekeew


code:

se= input()
wl= se.split()
ms=[]
for word in wl:
    ms+=[word[::-1]]
rls = " ".join(ms)
print(rls)




Comments

Popular posts from this blog

CODING ASSIGNMENT 3 Library Management

CODING PRACTICE 11 Music Page

CCBP Static Website Coding Assignment 2 Solution | Yoga Page