1# You can use 'in' on a dictionary to check if a key exists
2d = {"key1": 10, "key2": 23}
3"key1" in d
4# Output:
5# True
1d = {"apples": 1, "banannas": 4}
2# Preferably use .keys() when searching for a key
3if "apples" in d.keys():
4 print(d["apples"])
5
1if word in data:
2 return data[word]
3else:
4 return "The word doesn't exist. Please double check it."
1d = {"key1": 10, "key2": 23}
2
3if "key1" in d:
4 print("this will execute")
5
6if "nonexistent key" in d:
7 print("this will not")
8