🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: How Hashing Works: all 13 questions

Quiz: How Hashing Works · Question 13 of 13

Why can't a Python list be used as a dictionary key?

Why can't a Python list be used as a dictionary key?

  1. A.Lists are too large
  2. B.Lists cannot hold numbers
  3. C.Dictionaries only accept strings
  4. D.A list can change after insertion, so its hash would change; it is unhashable
Answer & explanation

Correct answer: A list can change after insertion, so its hash would change; it is unhashable

Use a tuple instead when you need a sequence as a key.

Can you get the rest right without peeking?

Take the timed Quiz: How Hashing Works quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →