Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up

Why can a tuple be used as a dictionary key but a list cannot?

  1. A Tuples are shorter
  2. B Tuples are immutable and therefore hashable
  3. C Lists are too slow
  4. D Dictionaries only accept sequences
Answer

Tuples are immutable and therefore hashable

Dictionary keys must be hashable, which requires immutability so the hash cannot change while the object is stored.

All Python MCQs

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as