Answers for "check if key is in dict"

2

if key in dictionary python

dict = {"key1": 1, "key2": 2}
if "key1" in dict:
 	print dict["key1]
>> 1
Posted by: Guest on October-07-2021
1

check if dict key contains specific key and value

if (key, value) in d.items():
	print("yes")
Posted by: Guest on November-16-2020

Code answers related to "check if key is in dict"

Python Answers by Framework

Browse Popular Code Answers by Language