O'Reilly logo
  • Peter Malmgren thinks this is interesting:

In step 2, we initialized the dictionary. Its empty when initialized. When a new key is added to a dictionary, accessing the dictionary through the new key will throw KeyError. In the preceding example in step 3, we included an if statement in the for loop to handle this situation. However, we can also use the following:

From

Cover of Python Data Science Cookbook

Note

what is this