reverse words python code example
Example 1: python reverse string
'String'[::-1] #-> 'gnirtS'
Example 2: how to reverse word order in python
## initializing the string
string = "I am a python programmer"
## splitting the string on space
words = string.split()
## reversing the words using reversed() function
words = list(reversed(words))
## joining the words and printing
print(" ".join(words))