Aan de slagGa gratis aan de slag

Subsetting lists

Now that you have your recipe scaler set up with the two lists (ingredients and quantities), you want to create a quick preview of your shopping list. You'll need to access specific items from your lists to display the first few ingredients and their amounts, as well as check what the last item on your list is.

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"]
quantities = [500, 400, 15, 20, 30, 10]

# Get the second ingredient for your preview
second_ingredient = ____

print(second_ingredient)
Code bewerken en uitvoeren