pairs = {1: "apple", "orange": [2, 3, 4], True: False, None: "True", } print(pairs.get("orange")) print(pairs.get(7)) p | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

pairs = {1: "apple", "orange": [2, 3, 4], True: False, None: "True", } print(pairs.get("orange")) print(pairs.get(7)) p

not in dictionary is not in pairs. why the have it in the result. it should be none.

26th Mar 2019, 6:33 PM
Smail Benloukil
Smail Benloukil - avatar
1 Answer
+ 9
"Not in dictionary" is not the output, it is more like an error. Because you are trying to get the value on "7" key. But actually, there is no key named "7" in your dictionary, so the system is telling you that the requested key is "not in dictionary"
26th Mar 2019, 6:39 PM
Letsintegreat
Letsintegreat - avatar