Python Reverse a List

There are a couple of ways to reverse a list in python: 1 2 3 4 5 my_list = [1,2,3,"apples","banana","fish","chicken"] reverse_list_one = my_list[::-1] reverse_list_one = reversed(my_list) reverse_list_zero = my_list reverse_list_zero.reverse() Of these three ways, I prefer using reversed because it is readable and there’s no ambiguity about whether it does it in place or not. It should be obvious to most people that .reverse() reverses a list in place, but I prefer the verbosity of the method that returns a reversed list....

April 13, 2025 · 3 min