Actually, to reverse any list in Python we have many ways and many efficient ways than other languages:-
The first thing you can use the reverse function which is in build function to reverse any data types in Python:-
array=[0,10,20,40]
for i in reversed(array):
print(i)
Important point to note is, the reversed() function does not return a list. Do get a reversed key you can use list(reversed(array)).
array=[0,10,20,40]
print(list(reversed(array))
The second method to do this problem which makes Python unique and best at the work compared to other language is by using the slice method:-
L = [0,10,20,40]
L[::-1]
To know more about this you can have a look at the following video tutorial:-
If you are looking for upskilling yourself in python you can join our Python Certification and learn from the industrial expert!