Python Kontroleer of sleutel in woordeboek bestaan
Kyk of sleutel in woordeboek bestaan
Om te bepaal of 'n gespesifiseerde sleutel in 'n woordeboek teenwoordig is, gebruik die in
sleutelwoord:
Voorbeeld
Kyk of "model" teenwoordig is in die woordeboek:
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
if "model" in thisdict:
print("Yes, 'model' is
one of the keys in the thisdict dictionary")