← Back to Algorithm Review

Reverse an Array

1 of 4

Exercise 1: Reverse an Array

πŸ“‹ Lists πŸ”‚ Loops

Your Task

Write a program that reverses a list. Do not use the built-in reverse() method β€” implement it yourself with a loop.

Example: [1, 2, 3, 4, 5] β†’ [5, 4, 3, 2, 1]

You can either:

  • Create a new list and build it in reverse order, or
  • Swap elements in place (more challenging)

Example Output

Original: [1, 2, 3, 4, 5]
Reversed: [5, 4, 3, 2, 1]

Try it yourself

Code: Reverse an Array

Loading Python runtime…
Python …
Loading...
bash
$ Click "Run" to execute your code...