We are given a string and we need to reverse words of a given string?
Input : str = geeks quiz practice code Output : str = code practice quiz geeks
This problem has existing solution please refer Reverse words in a given String link. We will solve this problem in python. Given below are the steps to be followed to solve this problem.
- Separate each word in given string using split() method of string data type in python.
- Reverse the word separated list.
- Print words of list, in string form after joining each word with space using ” “.join() method in python.
code practice quiz geeks
This article is contributed by Shashank Mishra (Gullu). If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.