Editor

Reverse a List Without reverse() or [::-1]

Intermediate · Write the code · from Python Lists: Create, Access, Modify, and Loop Through Lists

From the lesson: Python Lists: Create, Access, Modify, and Loop Through Lists

Think about your favorite music playlist. It has a bunch of songs stored in a specific order. You can add new songs, remove old ones, rearrange them, or skip to song number five.

Read the lesson

Reverse the given list using a loop. Do not use reverse(), reversed(), or [::-1].

Expected output:

[5, 4, 3, 2, 1]
original = [1, 2, 3, 4, 5]
# Reverse the list using a loop
# Print the reversed list

More Lists exercises

All Python exercises · 50 practice problems · Data Structures quiz