Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Modifying Functions
course content

Course Content

Introduction to Python

Modifying FunctionsModifying 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!


d.keys() is a method used with dictionaries that produces a list of all keys in the dictionary d. Here, it's utilized to verify whether the name 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?

Section 6. Chapter 9