0
Q:

check if key is present in dictionary

if word in data:
  return data[word]
else:
  return "The word doesn't exist. Please double check it."
9
if key in dict.keys(): 
1
d = {"key1": 10, "key2": 23}

if "key1" in d:
    print("this will execute")

if "nonexistent key" in d:
    print("this will not")
10

New to Communities?

Join the community