Answers for "get a key in dictionary python"

2

find a key in a dictionary python

# How to find a key / check if a key is in a dict

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

if 'apple' in fruits:
	print("Key found!")
else:
  	print("Key not found!")
Posted by: Guest on January-21-2021
-3

find key by value python

print(list(d.keys())[list(d.values()).index(990)])
Posted by: Guest on May-04-2020

Code answers related to "get a key in dictionary python"

Python Answers by Framework

Browse Popular Code Answers by Language