Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to find a key in a dictionary python

# Short way
fruits = {'apple': 2, 'pear': 5, 'strawberry': 3}

if fruits.get('apple'):
  print('Key found')
 
PREVIOUS NEXT
Tagged: #find #key #dictionary #python
ADD COMMENT
Topic
Name
7+7 =