How do i check if a key exists in a python dictionary?

Example:

my_dict = {'apple': 1, 'banana': 2}
key_exists = 'apple' in my_dict
Use the `in` keyword to check if a key exists in a dictionary in Python.

Beginner's Guide to Python