Reverse a List by Hand

easypy_basics

Implement reverse_iterative(lst).

Return a new list with the elements of lst in reverse order; leave the input unchanged. For example reverse_iterative([1, 2, 3]) == [3, 2, 1].

Use iteration only: the reversed builtin and slicing (lst[::-1]) are not allowed.

Constraints
  • no reversed

Your solution

Edit reverse_iterative and run the real pytest suite in your browser — no install required. Your code is saved locally.

⌘/Ctrl + ↵

Loading the Python runtime (first run only)…

Hints

Hint 1

Iterate indices from len(lst)-1 down to 0 with range(len(lst)-1, -1, -1) and append.