Exercise: Check if dictionary has key
Complete the function does_key_exist to print whether the person dictionary contains keys passed to the function as arguments.
person = {
'name': 'Bob',
'age': 30,
'city': 'New York'
}
def does_key_exist(key):
# add check here:
print(key, 'exists')
else:
print(key, 'does not exist')
does_key_exist('age')
does_key_exist('zipcode')
Python
Setting up Python environment...
Output