QuestenaÜben und erkennen, was als Nächstes dran ist
Frage 37

Why can a list not be used as a key in a Python dictionary?

  1. Lists are unhashable, while dictionary keys must be hashable.Richtige Antwort
  2. Lists are too large to fit in a dictionary entry.
  3. Only strings may be dictionary keys.
  4. A list would create several duplicate keys automatically.

Erklärung

Dictionary keys must be hashable, while a list can change its contents and is unhashable. Allowing arbitrary mutable keys would undermine stable lookup, and a dictionary cannot hold simultaneous duplicate equal keys.

Mit diesem Test weitermachen

Übung starten
Frage 37: Why can a list not be used as a key in a Python dictionary? · Python Fundamentals · Questena