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 a
Reversing in-place by switching references of opposite indices:
>>> l = [1,2,3,4,5,6,7] >>> for i in range(len(l)//2): ... l[i], l[-1-i] = l[-1-i], l[i] ... >>> l [7, 6, 5, 4, 3, 2, 1]