Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Dictionary basics
Dictionaries in loops and conditional statements
Dictionaries in functions
17. Summary


All right, it's time to wrap things up!

  • Dictionaries are defined within curly braces:

    phonebook = {'Mary': '8349374', 'Anne': '7439834', 'John': '3472983'}
  • Dictionary elements are accessed with keys in square brackets:

  • To add or update a dictionary element, use the following notation:

    phonebook['Mary'] = '3243563'
    phonebook['Jack'] = '3423457'
  • To delete a dictionary element, use:

    del phonebook['Mary']
  • To iterate over a dictionary, use:

    for key, value in phonebook.items():
      print(key, '=', value)
  • Dictionaries can be used as function arguments. They can also be returned from functions.

Time for a short quiz!


Click Next exercise to continue.