CBSE Class 11 Informatics Practices Question 48 of 66

Dictionary — Question 20

Back to all questions
20
Question

Question 10

How will you check for a value inside a dictionary using in operator?

Answer

We cannot directly check for a value inside a dictionary using in operator since in operator searches for a key in a dictionary. We can use values() function along with in operator to check for a value in dictionary as shown below:

>>> d = {1: 'a' , 2:'b'}
>>> 'b' in d.values()

Output

True