Advertisement
Programmin-in-Python

Reversing Each Word in a User-given Sentence

Apr 22nd, 2021
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.23 KB | None | 0 0
  1. def reverse_each_word():
  2.     sentence = input("Enter any Sentence : ")
  3.     words = sentence.split()
  4.     new_sentence = ""
  5.  
  6.     for i in words:
  7.         new_sentence += i[::-1] +  " "
  8.  
  9.     print(f"Formatted Sentence : {new_sentence}")
  10. reverse_each_word()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement