Dictionaries in python are similar to “associative arrays” in some other languages. Dictionaries are indexed by keys, which can be any immutable type, e.g strings and numbers.

Creating a dictionary

#Create a doctionary
my_dictionary = {}
my_dictionary["MyKeyA"] = "Something"
my_dictionary["MyKeyB"] = "Something else"

#Alternative method

my_dictionary = {"MyKeyA": "Something", "MyKeyB": "Something else"}

Accessing a dictionary

print(my_dictionary["MyKeyB"])

Does dictionary key exist?

    if 'MyKeyName' in my_dictionary:
        print("MyKeyName: " + my_dictionary['MyKeyName'])