Aan de slagGa gratis aan de slag

Looping through a list

You're doing a trial run of cooking the pasta dish. First, you need to list all your ingredients to make sure you have everything ready.

Then, you'll add them one by one as you cook — seven ingredients in total.

Deze oefening maakt deel uit van de cursus

Introduction to Python for Developers

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

ingredients = ["fusilli", "tomatoes", "garlic", "basil", "olive oil", "salt"]

# Loop through each ingredient in the list
for ____ in ____:
    print(item)
Code bewerken en uitvoeren