# 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
# Python code
#To reverse list
#input list
lst=[10, 11, 12, 13, 14, 15]
# the above input can also be given as
# lst=list(map(int,input().split()))
l=[] # empty list
# checking if elements present in the list or not
for i in lst:
#reversing the list
l.insert(0,i)
# printing result
print(l)
# Reversing a list using reversed()
def Reverse(lst):
return [ele for ele in reversed(lst)]
# Driver Code
lst = [10, 11, 12, 13, 14, 15]
print(Reverse(lst))
# create a list of prime numbers
prime_numbers = [2, 3, 5, 7]
# reverse the order of list elements
prime_numbers.reverse()
print('Reversed List:', prime_numbers)
# Output: Reversed List: [7, 5, 3, 2]