Source Code:
(back to article)
my_dict = {"a": 1, "b": 2} # Using .get() method value = my_dict.get("c", "Key not found") print(value) # Using `in` keyword if 'c' in my_dict: print(my_dict['c']) else: print("Key not found")
Result:
Report an issue