What would you used instead of XXX if you want to check weather a certain ‘key’ exists in a dictionary called dict? (Select two answers)

What would you used instead of XXX if you want to check weather a certain ‘key’ exists in a dictionary called dict? (Select two answers)

A . ‘key’ in dict
B . dict [‘key’] != None
C . dict.exists (‘key’)
D . ‘key’ in dict.keys ( )

Answer: BD

Explanation:

Reference: https://thispointer.com/python-how-to-check-if-a-key-exists-in-dictionary/

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments