Editor

Numbered Menu

Beginner · Write the code · from Python For Loops: Iterate Over Anything with Examples

From the lesson: Python For Loops: Iterate Over Anything with Examples

Imagine you're a teacher with 30 students. You need to print a report card for each one. Would you write 30 separate print statements? Of course not. You'd tell the computer: "for each student, print their report card." That's exactly what a for loop does.

Read the lesson

Use enumerate() with start=1 to print a numbered restaurant menu.

Expected output:

1. Burger - $8.99
2. Pizza - $12.50
3. Salad - $7.25
4. Pasta - $10.00
items = ["Burger", "Pizza", "Salad", "Pasta"]
prices = [8.99, 12.50, 7.25, 10.00]
# Use enumerate() and zip() to print the numbered menu

More For Loops exercises

All Python exercises · 50 practice problems · Control Flow quiz