reverse the words in a string python

Do you want to know the information regarding “reverse the words in a string python”. If yes, you’re in the correct tutorial.

reverse the words in a string python

# in order to make a string reversed in python 
# you have to use the slicing as following

string = "racecar"
print(string[::-1])
'hello world'[::-1]
'dlrow olleh'
string = 'hello people of india'
words = string.split()   #converts string into list
print(words[::-1])

Final Thoughts

I hope this tutorial helps you to know about “reverse the words in a string python”. If you have any questions regarding this article please let us know via the comment section. Share this tutorial with your friends & family via social networks.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coder Diksha. Here, I post about programming to help developers.

Share on:

Leave a Comment