Get startedGet started for free

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

This exercise is part of the course

Python for MATLAB Users

View Course

Hands-on interactive exercise

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

# Create dict with milk and apples
groceries = {____:____, 
             ____:____}

print(groceries)
Edit and Run Code