Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.2k
Closed as not planned
Description
Bug report
Bug description:
I don't know if it's bug or not. A dictionary key acceptsint
,float
,complex
,bool
and a tuple as shown below:
v= {2:3,2.3:4.5,2.3+4.5j:6.7+8.9j,True:False, (2,3):(4,5)}print(v[2],v[2.3],v[2.3+4.5j],v[True],v[(2,3)])# 3 4.5 (6.7+8.9j) False (4, 5)
In addition, a dictionary key doesn't accept a list, set and dictionary as shown below:
v= {[2,3]:[4,5]}print(v[[2,3]])# TypeError: unhashable type: 'list'
v= {{2,3}:{4,5}}print(v[{2,3}])# TypeError: unhashable type: 'set'
v= {{'a':'b'}:{'c':'d'}}print(v[{'a':'b'}])# TypeError: unhashable type: 'dict'
CPython versions tested on:
3.12
Operating systems tested on:
Windows