You can check if a key exists in a Python dictionary using the in operator. The in operator matches the key against dictionary and checks for the presence of key.
example
my_dict = {'name': 'TutorialsPoint', 'time': '15 years', 'location': 'India'} print('name' in my_dict) print('foo' in my_dict)
Output
This will give the output −
True False