Existence of a key can be checked by .get() method of a dictionary

# Let's create a dictionary
nicknames = {'Thor': 'Asgardian', 'Parker': 'Spydie', 'Iron Man': 'Son of a gun'}
# dict.get() method returns value if a key is present
print(nicknames.get('Thor'))
Asgardian
# dict.get() method returns None if a key is absent
print(nicknames.get('Avengers'))
None
# While trying to fetch directly will result in key error
nicknames['Avengers']
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-13-e1bfbf5cec24> in <module>()
      1 # While trying to fetch directly will result in key error
----> 2 nicknames['Avengers']

KeyError: 'Avengers'

That's how we Check if a key exists in a dictionary

That’s all for this mini tutorial. To sum it up, we learned how to Check if a key exists in a dictionary. 

Hope it was easy, cool and simple to follow. Now it’s on you.