Editor

Reverse a List

#14 · Lists · Beginner · 45 XP · about 5 min

Write a function called reverse_list(lst) that returns a new list with elements in reverse order.

Challenge: Try to solve this without using Python's built-in reverse() method or [::-1] slicing!

Example

reverse_list([1, 2, 3, 4, 5])  # Returns [5, 4, 3, 2, 1]
reverse_list(["a", "b", "c"])  # Returns ["c", "b", "a"]
reverse_list([1])              # Returns [1]

Requirements

  • Return a new reversed list (don't modify the original)
  • Handle lists of any type
  • Handle empty lists

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.