1. Learn
  2. /
  3. Courses
  4. /
  5. Python for MATLAB Users

Connected

Exercise

Modifying dictionaries

Like lists, dictionaries can be changed. You can add new key:value pairs, update existing pairs, remove pairs. In this exercise, you'll explore creating and modifying dictionaries by creating the grocery list below.

  • 1 gallon of milk
  • 4 apples
  • 1 loaf of bread
  • 3 avocados
  • 2 candy bars

Instructions 1/4

undefined XP
    1
    2
    3
    4
  • Create a dictionary groceries with the keys gallons of milk and apples, with the values 1 and 3, respectively.