# To reverse a list use simply: reverse() method
# Example
list = [1, 2, 3]
list.reverse()
# Output
[3, 2, 1]
# to reverse any other type, we can use reversed()
# The reversed() function returns an iterator that accesses the given sequence in the reverse order.
# Example
list = [1, 2, 3]
list(reversed(list))
# Output
[3, 2, 1]
# reversed() returns an iterator so we can loop over it
# Example
for num in reversed(list):
print(num)
# Output
3
2
1
# 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]
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()