¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita0
Can anyone please explain me how, using [1,2,3] as a key will return "type error"?
2 Respuestas
+ 2
Because [1,2,3] is a list which is a mutable object and hence can't be used as a key because keys can only be immutable objects.
+ 2
Notice how "[1,2,3]" is enclosed in brackets? That means it's a list in Python, and by definition, lists are mutable (i.e., changeable). You aren't allowed to use mutable items for dictionary keys.