How to Reverse a List in Python
my_list.reverse() to reverse a list in place, or my_list[::-1] to get a new reversed list. reversed(my_list) gives an iterator you can loop over or wrap in list().Reversing a list is common when you want the newest item first, process a stack from the top, or walk through data backwards. Python has three standard tools, and the key difference is whether the original list changes.
If you also want to sort, see sorting lists; reverse() only flips the current order and does not compare values.
| In place | my_list.reverse() (returns None) |
|---|---|
| New list | my_list[::-1] or list(reversed(my_list)) |
| Iterate backwards | for x in reversed(my_list): |
| Time complexity | O(n) |
Reverse a list in place with list.reverse()
The reverse() method rearranges the list you call it on and returns None. Use it when you no longer need the original order.
letters = ["a", "b", "c"]
letters.reverse()
print(letters)Get a reversed copy with slicing [::-1]
A slice with step -1 walks the list from the end to the start and builds a new list. The original stays unchanged, which is ideal when you need both orders.
letters = ["a", "b", "c"]
print(letters[::-1])
print(letters)Loop backwards with reversed()
The built-in reversed() returns an iterator that yields items from last to first without copying the list. Wrap it in list() if you need an actual list. Use it in a for loop when you only want to read the items.
scores = [70, 85, 90]
for s in reversed(scores):
print(s)
reverse() vs [::-1] vs reversed()
| Tool | Changes original? | Returns | Memory |
|---|---|---|---|
lst.reverse() | Yes | None | No copy |
lst[::-1] | No | New list | Copy of the list |
reversed(lst) | No | Iterator | No copy until you build a list |
list(reversed(lst)) | No | New list | Copy of the list |
Examples you can run
Press Run, then edit the code and run it again.
Reverse in place
The list itself is changed and reverse() returns None.
queue = ["first", "second", "third"]
result = queue.reverse()
print(queue)
print(result)Expected output['third', 'second', 'first']
None
Keep the original and get a reversed copy
Slicing builds a new list, so both orders are available.
scores = [70, 85, 90]
latest_first = scores[::-1]
print(latest_first)
print(scores)Expected output[90, 85, 70]
[70, 85, 90]
reversed() returns an iterator
Convert it with list() to see the items.
nums = [1, 2, 3]
it = reversed(nums)
print(list(it))
print(nums)Expected output[3, 2, 1]
[1, 2, 3]
Edge cases: empty and one-item lists
All methods handle them without errors.
print([][::-1])
print([5][::-1])
empty = []
empty.reverse()
print(empty)Expected output[]
[5]
[]
Common mistakes
Assigning the result of reverse()
✗ Wrong
nums = [1, 2, 3]
nums = nums.reverse()
print(nums)✓ Right
nums = [1, 2, 3]
nums.reverse()
print(nums)reverse() changes the list and returns None. Do not assign its result.
Printing a reversed() object
✗ Wrong
nums = [1, 2, 3]
print(reversed(nums))✓ Right
nums = [1, 2, 3]
print(list(reversed(nums)))reversed() returns an iterator. Wrap it in list() to see the values.
Reversing a list while keeping an alias
✗ Wrong
a = [1, 2, 3]
b = a
b.reverse()
print(a)✓ Right
a = [1, 2, 3]
b = a[::-1]
print(a)b = a makes two names for one list. Copy first with b = a[::-1] or a.copy().
How to Reverse a List in Python: questions people ask
How do I reverse a list in Python without changing the original?
Use slicing, my_list[::-1], or list(reversed(my_list)). Both return a new list and leave the original untouched.
What is the difference between reverse() and reversed() in Python?
reverse() is a list method that flips the list in place and returns None, while reversed() is a built-in function that returns an iterator over the items from last to first.
How do I reverse a string or a tuple the same way?
Strings and tuples are immutable and have no reverse() method, but slicing x[::-1] and reversed(x) both work on them.
Keep learning
Step-by-step lessons:
Python ListsPython SlicingPython List Methods
Related:
Python List reverse() MethodPython reversed() FunctionHow to Reverse a String in PythonPython sort() vs sorted(): What Is the Difference?
More in lists, dicts and sets:
How to Remove Duplicates from a List in PythonHow to Sort a Dictionary by Value in PythonHow to Merge Two Dictionaries in PythonHow to Flatten a List of Lists in PythonHow to Check if a List Is Empty in PythonHow to Get the Last Element of a List in PythonHow to Loop Through a Dictionary in PythonHow to Count Occurrences in a List in Python See all →