Can a dictionary key be a tuple?

  1. Yes, if the tuple contains only immutable elements
  2. Yes, any tuple is allowed
  3. No, tuples are not hashable
  4. Only in Python 2
Correct answer Yes, if the tuple contains only immutable elements

Explanation

Only tuples with immutable contents can be used as dictionary keys.

Update: Admin added a tag on this question

Topics

By Admin · · 33 views