printing none value | Sololearn: Learn to code for FREE!

+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"

3/26/2017 1:25:00 PM

Vaibhav Singh

2 Answers

New Answer

+2

print(pairs.get(7, True)) Oh BTW, None evaluates to False (not True) when coerced into Boolean type.

+2

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