How to check if a given key already exists in a Python dictionary?

You can use in operator in Python to check if a key or value exists in Python dictionary as shown in the below example –