+ 1

dictionaries

Only immutable objects can be used as keys to dictionaries. Immutable objects are those that can't be changed. So far, the only mutable objects you've come across are lists and dictionaries. Trying to use a mutable object as a dictionary key causes a TypeError. could you explain more? I am clear with this.

19th Apr 2020, 12:55 AM
PRIYANKA K
PRIYANKA K - avatar
4 Respuestas
+ 1
If you want to understand in detail, I suggest you to refer to this website: http://net-informations.com/JUMP_LINK__&&__python__&&__JUMP_LINK/iq/immutable.htm
19th Apr 2020, 2:26 AM
Tricker
+ 1
Mutable means modifiable. Ex: lists, dictionaries. Immutable means cannot be modifiable. Ex: Touples, strings.. Dictionary keys must be immutable. You can change values but not key. If keys are changeable, then other part code may change its values, then you get difficulty in accessing values or you can predict which value stored in which key so Program goes into undefined behaviour.. So that's why it is not allowed to use as keys.
19th Apr 2020, 6:03 AM
Jayakrishna 🇮🇳
0
amog us
29th Jan 2022, 8:40 PM
youssef
0
thank you, Jayakrishna
8th Aug 2023, 10:54 AM
Jaleh Dabirsepehri
Jaleh Dabirsepehri - avatar