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

Instruction

Good! To access a dictionary element, we can use its key within square brackets:

phonebook = {'Mary': '8349374', 'Anne': '7439834', 'John': '3472983'}
phonebook['Anne'] # returns '7439834'

This works just like it does in lists. The only difference is that you need to provide a key, not an index.

Remember: dictionaries contain unordered data.

Exercise

Print the name of the Windows operating system released in 2012.

Stuck? Here's a hint!

Use square brackets with the key (year) inside.