# Day-02 dict .get()
my_dict = {'hello': 'world'}
try:
my_dict['world']
# Throws KeyError exception
except KeyError:
print('Cannot find the provided key in the dictionary')
# Use .get() to be safe from the exception
print(my_dict.get('world'))
# prints None in the console
# You can pass second argument as default value
print(my_dict.get('world', 'default value'))
# prints 'default value'
Read next

React Clean Code - Simple ways to write better and cleaner code
Tyler Hawkins -

Leaflet onClick event
Allan Simonsen -

Lists in Python Part-1
Aditi Jha -

5 Tips for Getting Over Your Fear of Math
Taryn McMillan -
Discussion (2)
I like it, very short and simple but clear. Thanks!
I am glad you liked it ☺️