Course Content
Introduction to Python
Introduction to Python
Modifying Functions
Let's revisit the example with the country information. What happens if the name
parameter isn't found in the data?
Can we manage this problem? Absolutely, by implementing conditional statements!
Note
d.keys()
is a method used with dictionaries that produces a list of all keys in the dictionaryd
. Here, it's utilized to verify whether thename
is present in the dictionary's keys.
As demonstrated, the error message in this updated format is more user-friendly. While there are many other potential errors and methods to handle them, they're outside the purview of this course.
Everything was clear?