423 B
423 B
title, tags, expertise, author, firstSeen, lastUpdated
| title | tags | expertise | author | firstSeen | lastUpdated |
|---|---|---|---|---|---|
| Key in dictionary | dictionary | beginner | maciv | 2020-10-16T21:30:49+03:00 | 2020-10-16T21:30:49+03:00 |
Checks if the given key exists in a dictionary.
- Use the
inoperator to check ifdcontainskey.
def key_in_dict(d, key):
return (key in d)
d = {'one': 1, 'three': 3, 'five': 5, 'two': 2, 'four': 4}
key_in_dict(d, 'three') # True