all Python 3Lists (list)function
list.reverse
sorting
Reverse the list in place. For a new reversed iterator without mutating, use the built-in reversed().
Syntax
lst.reverse()
Like every method that mutates a list in place, reverse() returns None, so lst = lst.reverse() throws the list away and leaves you with None. reversed() copies nothing: it walks the list lazily from the end and therefore reflects changes made while you iterate, but it works on any sequence, whereas reverse() exists only on lists.
Examples
lst = [1, 2, 3]
lst.reverse()
print(lst) # → [3, 2, 1]
chars = ['a', 'b', 'c']
chars.reverse()
print(chars) # → ['c', 'b', 'a']
See also
Open in the full glossarydocs.python.orgReport an inaccuracy