1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Python for Developers

Connected

Exercise

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.

Instructions 1/3

undefined XP
  • 1
    • Access the second ingredient from the ingredients list and assign it to second_ingredient.
  • 2
    • Get the last item from the quantities list using slice notation and assign it to last_quantity.
  • 3
    • Extract every other element from the ingredients list, starting with the first and assigning it to alternate_ingredient.