something like this but in a defined function
# Check if a key exists in a dictionary
info = {'Breakfast': 'Egg', 'time' :'05:30 am'}
if 'lunch' in info.keys():
print('Exists!')
else:
print("Doesn't exist!")
something like this but in a defined function
# Check if a key exists in a dictionary
info = {'Breakfast': 'Egg', 'time' :'05:30 am'}
if 'lunch' in info.keys():
print('Exists!')
else:
print("Doesn't exist!")
Here's a one liner: