VOOZH about

URL: https://www.geeksforgeeks.org/python/python-reversing-list/

⇱ Reversing a List in Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Reversing a List in Python

Last Updated : 29 May, 2026

Given a list, the task is to reverse the order of its elements. Example:

Input: [10, 20, 30, 40, 50]
Output: [50, 40, 30, 20, 10]

Let's see different methods to reverse a list.

Using reverse()

reverse() method reverses the elements of the list in-place and it modifies the original list without creating a new list.


Output
[5, 4, 3, 2, 1]

Using List Slicing

This method builds a reversed version of the list using slicing with a negative step.


Output
[5, 4, 3, 2, 1]

Explanation:

  • a[::-1] walks through the list from end to start.
  • rev holds the new reversed list while a stays unchanged.

Using reversed()

Python's built-in reversed() function is another way to reverse the list. However, reversed() returns an iterator, so it needs to be converted back into a list.


Output
[5, 4, 3, 2, 1]

Using a Loop

If we want to reverse a list manually, we can use a loop (for loop) to build a new reversed list. This method is less efficient due to repeated insertions and extra space required to store the reversed list.


Output
[5, 4, 3, 2, 1]

Explanation:

  • i starts at the beginning and j at the end.
  • a[i], a[j] = a[j], a[i] swaps corresponding elements.
  • Loop continues until both pointers meet.
Comment
Article Tags: