MyCODE
mydict={True:'Visa',2:"verified",1:'Married',(111,222):'dept1 office 2'}
print(f"mydict.get(True)---> {mydict.get(True)}")
print(f"mydict.get(2)---> {mydict.get(2)}")
print(f"mydict.get(1)---> {mydict.get(1)}")
print(f"mydict.get((111,222))---> {mydict.get((111,222))}")
OUTPUT
mydict.get(True)---> Married
mydict.get(2)---> verified
mydict.get(1)---> Married
mydict.get((111,222))---> dept1 office 2
My question is why mydict.get(True)---> Married ...It should be Visa right...why it happened that?
CodePudding user response:
One of the great show-effects in Python, based on the fact that you cannot have multiple equal keys (as in ==
-equal)
>>> {1: "one", True: "true", 1.0: "ok", 0.99999999999999999: "weird"}
{1: 'weird'} #