Editor

Sum All Numbers Using a Loop

Beginner · 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

Write a program that calculates the sum of all numbers in the list using a for loop. Do not use the built-in sum() function.

Expected output:

150
numbers = [10, 20, 30, 40, 50]
# Calculate the total using a for loop
# Print the total

More Lists exercises

All Python exercises · 50 practice problems · Data Structures quiz