What does `’a’ in {‘a’: 1, ‘b’: 2}` return?

Python Developer Easy

Python Developer — Easy

What does `’a’ in {‘a’: 1, ‘b’: 2}` return?

Key points

  • The 'in' keyword checks for membership in a dictionary.
  • The expression returns True if the key is present.
  • This is different from checking for the value in a dictionary.

Ready to go further?

Related questions