+ 1
pairs = {1: "apple", "orange": [2, 3, 4], True: False, 12: "True", } print(pairs.get("orange")) print(pairs.get(7, 42))
Here what is the use of print((pairs.get(7,42))
4 Answers
+ 3
Your program tell get() method to return a default value instead of None if key-value pair does not exist.
Use to handle exception(NoneType)
+ 2
Try get value by key 7 if value don't exist in dictionary return 42
0
If u change 7 on 12 will return True
0
TQ