#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)
Function ReverseArray(arr As Variant) As Variant
Dim val As Variant
With CreateObject("System.Collections.ArrayList") '<-- create a "temporary" array listwith late binding
For Each val In arr '<--| fill arraylist
.Add val
Next val
.Reverse '<--| reverse it
ReverseArray =.Toarray '<--| write it into an array
End With
End Function
#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