Get startedGet started for free

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.

This exercise is part of the course

Introduction to Python for Developers

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

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)
Edit and Run Code