Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python check if key exists

d = {"apples": 1, "banannas": 4}
# Preferably use .keys() when searching for a key
if "apples" in d.keys():
  print(d["apples"])
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #check #key #exists
ADD COMMENT
Topic
Name
7+3 =