how to reverse in python code example

Example 1: reverse in python 3

# create list of integers or strings 
number = [1,2,3,4,5]
# pass the values using the reverse method.
number.reverse()
# Then print the variable as such:
print(number)

Example 2: reverse list python

list=[1,2,3]
list[::-1]

Example 3: python reverse list

# Operating System List
systems = ['Windows', 'macOS', 'Linux']
print('Original List:', systems)

# Reversing a list	
#Syntax: reversed_list = systems[start:stop:step] 
reversed_list = systems[::-1]

# updated list
print('Updated List:', reversed_list)

Example 4: reverse function python

# The Reverse operation - Python 3:
Some_List = [1, 2, 3, 4, 1, 2, 6]  
Some_List.reverse()  
print(Some_List)
# Result: [6, 2, 1, 4, 3, 2, 1]

Example 5: reverse python3

arr = [2,5,32,86,4,131,97]

# reverse without modifying input, using range:
for i in range(len(arr)-1, -1, -1):
    print(arr[i])
    
# reverse and modifying input:
arr.reverse()