Computer Science

Write a program to input a line of text and create a new line of text where each word of input line is reversed.

Python

Python String Manipulation

17 Likes

Answer

str = input("Enter a string: ")
words = str.split()
newStr = ""

for w in words :
    rw = ""
    for ch in w :
        rw = ch + rw
    newStr += rw + " "

print(newStr)

Output

Enter a string: Python is Fun
nohtyP si nuF

Answered By

5 Likes


Related Questions