Can anyone please explain me how, using [1,2,3] as a key will return "type error"?

7th Jan 2016, 1:00 PM
Nikhil Dhyani
Nikhil Dhyani - avatar
2 Answers
+ 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.
9th Mar 2016, 4:05 PM
Anjum Meer
+ 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.
13th Mar 2016, 7:32 PM
Holden  - avatar