Skip to content

Check if a key exists in a dictionary

Advertisements
dictionary = {'class': 'X', 'age': 16, 'score': 88, 'name': 'Anand', 'sex': 'Male'}

print ('name' in dictionary)

#True

print ('address' in dictionary)

#False
See also  How to take fast input in Python?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.