← 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?
- A.Lists are too large
- B.Lists cannot hold numbers
- C.Dictionaries only accept strings
- 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 →