+ 2
printing none value
pairs = {1: "apple", "orange": [2, 3, 4], True: False, None: "Key Not present", } print(pairs.get("orange")) print(pairs.get(7)) print(pairs.get(12345, "not in dictionary")) Output: [2, 3, 4] None not in dictionary In print(pairs.get(7)) it prints "None" , can we instead of printing "None", print the value of "None" i.e. "True"
2 odpowiedzi
+ 3
pairs = {1: "apple",
"orange": [2, 3, 4],
True: False,
None :True
}
print(pairs.get("orange"))
print(pairs.get(7,))
print(pairs.get(12345, "not in dictionary"))
print(pairs.get(None))
Output:
[2,3,4]
None
not in dictionary
True
this really made me understand
+ 2
print(pairs.get(7, True))
Oh BTW, None evaluates to False (not True) when coerced into Boolean type.