QuestenaPráctica que te muestra qué repasar después
Pregunta 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.Respuesta correcta
  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.

Explicación

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.

Continúa con este test

Empezar la práctica
Pregunta 37: Why can a list not be used as a key in a Python dictionary? · Python Fundamentals · Questena