List Methods
reverse()
Reverse the elements of the list in place.
list.reverse()
list.reverse() reverses the order of elements directly inside the list without creating a new copy.
Because it operates in place, it uses O(1) extra memory.
Returns
None — the list is reversed in place.
Try it
Run it and change it
countdown = [1, 2, 3, 4, 5] countdown.reverse() print(countdown)
Worth knowing
- reverse() vs reversed():
list.reverse()modifies the list in place and returnsNone. The built-inreversed(list)returns an iterator leaving the original list unchanged.