#This option produces a reversed copy of the list. Contrast this to mylist.reverse() which#reverses the original list>>> mylist
[1,2,3,4,5]>>> mylist[::-1][5,4,3,2,1]
# 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# Examplefor num inreversed(list):print(num)# Output321
# 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 notfor i in lst:#reversing the list
l.insert(0,i)# printing resultprint(l)
# 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]
#This option reverses the original list, so a reversed copy is not made>>> mylist =[1,2,3,4,5]>>> mylist
[1,2,3,4,5]>>> mylist.reverse()None>>> mylist
[5,4,3,2,1]
https://dbader.org/blog/python-reverse-list