- In dictionary of python contains two things i.e. keys and values.
- It is possible to have the multiple values for one key in dictionary but it is not possible to put multiple keys for one value.
- When we try to make multiple similar keys for different values then it gives a warning like dictionary key 'keyname' repeated for different values. but it not give any error in program.
Example
d={1:"one",1:"two"}
- here we have a two keys with same name so dictionary bydefault choose the last key and their values.
program-
d={1:"one",1:"two"}
print(d,d[1])
d={1:"one",1:"two",1:"three"}
print(d,d[1])
d={1:1,1:2,1:3}
print(d,d[1])
{1: 'two'} two
{1: 'three'} three
{1: 3} 3
l=["one","two"]
d={1:l}
print(d)
{1: ['one', 'two']}