write a program which takes a sentence and prints that sentence in reverse order in Python programming
Answers
Answered by
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
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
English,
7 months ago
Math,
1 year ago
English,
1 year ago
Math,
1 year ago
India Languages,
1 year ago