DEV Community

Cover image for Ibuprofeno.py💊| #109: Explica este código Python
Cristian Fernando
Cristian Fernando

Posted on • Edited on

Ibuprofeno.py💊| #109: Explica este código Python

Explica este código Python

Dificultad: Intermedio

d = {[1, 1]: 'a', [1, 2]: 'b', [2, 1]: 'c', [2, 2]: 'd'}
print(d[[1,1]])
Enter fullscreen mode Exit fullscreen mode

👉 A. a
👉 B. NameError
👉 C. TypeError
👉 D. Ninguna de las anteriores


Respuesta:

👉 C. TypeError

Las claves de un diccionario deben ser siempre inmutables, como por ejemplo, una cadena, un número, un booleano o una tupla. No pueden ser ni listas ni otros diccionarios (ambos son mutables).

Top comments (0)

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay