Dictionary basics
4. Accessing nonexistent dictionary elements
Dictionaries in loops and conditional statements
Dictionaries in functions


Good job with accessing dictionary elements! A word of warning, though.

Be careful when you use keys within square brackets. If a key is not present in the dictionary, you will see a nasty error, and your code will crash. Let's see that in practice.


Run the template code. We're trying to access a key that is not present in the dictionary.

As you can see, an error appears. We'll learn more about handling such situations in the next part of the course.