0 votes
1 view
in Python by (47.8k points)

How can I do the following in Python?

array = [0, 10, 20, 40] 

for (i = array.length() - 1; i >= 0; i--)

I need to have the elements of an array, but from the end to the beginning.

1 Answer

0 votes
by (107k points)

Simply use the below-mentioned method to reverse a list in a Python:-

>>> L = [0,10,20,40] 

>>> L[::-1] 

[40, 20, 10, 0]

Related questions

0 votes
1 answer
asked Jul 3, 2019 in Python by Sammy (47.8k points)
+1 vote
2 answers
+3 votes
2 answers
0 votes
1 answer
asked Oct 11, 2019 in Python by Sammy (47.8k points)
+2 votes
3 answers
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...