English

Assuming that D1 is a dictionary in Python. Write a Python expression to check if any key in D1 has a value 12. - Computer Science (Python)

Advertisements
Advertisements

Question

Assuming that D1 is a dictionary in Python.

Write a Python expression to check if any key in D1 has a value 12.

Very Short Answer
Advertisements

Solution

To check if the value 12 is present in the dictionary D1, you can use the in operator along with the .values() method.
12 in D1.values()
shaalaa.com
  Is there an error in this question or solution?

APPEARS IN

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×