+ 4
Can we use tuple as a key in dictionary always? Or there is any condition
7 Answers
+ 2
You can't use tuples of mutable objects (for example tuples of dictionaries) as keys, because those are mutable.
+ 6
If "hash(obj)" doesn't raise any errors you can use it as a key
+ 3
Keys have to be immutable, otherwise they would make the whole concept of a dictionary senseless. So yes, tuples of any kind can work as keys no problem.
+ 2
you can, please post a code for your try
+ 2
Mert Yazıcı "hash(obj)" is a functions ?
+ 2
s u can only when it is immutable