python how to print in reverse order code example
Example 1: reverse string in python
'hello world'[::-1]
'dlrow olleh'
Example 2: print list in reverse order python
languages = ['C++', 'Python', 'Scratch']
#Method1:
languages.reverse()
print(languages)
#Method2:
lang = languages[::-1]
print(lang)
Example 3: reverse list python
list=[1,2,3]
list[::-1]