|Reverse a List
All Challenges

Reverse a List

EasyLists

Given a list lst, return a new list with the elements in reversed order.


Do not use .reverse() or [::-1] — implement the reversal yourself.


Think of this like reversing a queue of items in a warehouse management system. You need to process the last item added first.

Examples

Input: reverse_list([1, 2, 3, 4, 5])
Output: [5, 4, 3, 2, 1]
Simple integer list
Input: reverse_list(["a", "b", "c"])
Output: ["c", "b", "a"]
Works with strings too
Input: reverse_list([42])
Output: [42]
Single element
Input: reverse_list([])
Output: []
Empty list returns empty

Constraints

  • 0 <= len(lst) <= 10,000
  • List elements can be any type
  • Do not use .reverse() or slicing [::-1]
pythoneditor
Loading Python runtime…