How to check if a given key already exists in a dictionary?
def key_exists(dictionary, key):
    return key in dictionary

sample_dict = {'a': 1, 'b': 2, 'c': 3}
print(key_exists(sample_dict, 'b'))  # Output: True
print(key_exists(sample_dict, 'd'))  # Output: False
