Skip to content


Related course:


Python supports a data structure known as dictionary:  a set which contains key, value pairs. For every key in a dictionary,  there is a value. Unlike lists, dictionaries do not have an specific order.

Type the code below and run it:


words = {}
words["BMP"] = "Bitmap"
words["BTW"] = "By The Way"
words["BRB"] = "Be Right Back"

print words["BMP"]
print words["BRB"]

You should see


Try the exercises below

1. Create a dictionary that maps these cities to the acronyms (NY,LA,AC,AM):
   list = [ "New York", "Los Angles", "Atlantic City", "Amsterdam" ]

After completing these continue with the next exercise.


Read file


  1. Shaun Shaun

    I ran into an error with the code listed here. It flags me that I’m missing parenthesis in call to print. I fixed this by adding parenthesis such as print(words[“BMP”]). I don’t know if this is a typo or some other error, but it works with my solution.

Leave a Reply