Almost all of types of values can be used as dictionary key with Python. We just saw this example, where the object is integer, float, and Boolean is used as the key.
There are some limitations that must be followed by dict key.
First, the key is given only can emerge once a time in dict. The duplicate key is not allowed. dict is mapping each of key to respective value that is suitable, so it does not make any sense to map certain keys more than once.
We can see above that when we state the value into dict key that has existed. It does not add key for the second time but replace the existing value.
Second, dict key must be from type that have never been changed. We have seen the example where some type that cannot be change that we recognize as integer, float, string and Boolean have been functioning as dict key.
Its vice versa, there is no such limitation on dict value. Literally there is nothing. dict Value can be all of object types that is supported by Python. It is including the type that can be changed such as list and dict and object that is determined by the user. There is no limitation as well toward certain value that emerge in dict sometimes.
foo = {42: 'aaa', 2.78: 'bbb', True: 'ccc'}
d = {int: 1, float: 2, bool: 3}
d = {bin: 1, hex: 2, oct: 3}
{'Liverpool': 'Liverpool',
'Chelsea': 'London',
'Manchester United': 'Manchester',
'Manchester City': 'Manchester',
'Arsenal': 'London',
'New Castle United': 'New Castle',
'West Ham United': 'Birmingham'}
key dict
**must immutable