Computer Science, asked by ekanah, 1 year ago

write a program which takes a sentence and prints that sentence in reverse order in Python programming

Answers

Answered by dhyanjpatel2003
3

Input:

# Python code to Reverse each word  

# of a Sentence individually  

 

# Function to Reverse words  

def reverseWordSentence(Sentence):  

 

   # All in One line  

   return ' '.join(word[::-1] for word in Sentence.split(" "))  

 

# Driver's Code  

Sentence = "Geeks for Geeks"

print(reverseWordSentence(Sentence))      


Output:    

skeeG rof skeeG

Answered by fiercespartan
0

Hey there!!

In order to print the sentence backwards, I personally use this code:

sentence = 'Hi, I am a coder'

sentence = sentence.split()

sentence = reversed(sentence)

print('  '.join(sentence))

Hope my answer helps! :)

Similar questions