1dct.get(key, 'ham') # will return dct[key] or 'ham' but never stores anything
2
1'in' is the intended way to test for the existence of a key in a dict.
2
3d = {"key1": 10, "key2": 23}
4
5if "key1" in d:
6 print("this will execute")
7
8if "nonexistent key" in d:
9 print("this will not")