Python Lists and Dictionaries
This Next Part is Key

A dictionary is similar to a list, but you access values by looking up a key instead of an index. A key can be any string or number. Dictionaries are enclosed in curly braces, like so:

d = {'key1' : 1, 'key2' : 2, 'key3' : 3}

This is a dictionary called d with three key-value pairs. The key 'key1' points to the value 1, 'key2' to 2, and so on.

Dictionaries are great for things like phone books (pairing a name with a phone number), login pages (pairing an e-mail address with a username), and more!


Print the values stored under the 'Sloth' and 'Burmese Python' keys. Accessing dictionary values by key is just like accessing list values by index:

# Gets the value 104

Check the Hint if you need help!

Stuck? Get a hint! Hint
Get live, fast support from Codecademy Advisors when you get stuck. Learn more.

As an example, code has been provided that prints the value stored under the 'Puffin' key. The code on line 4 It will print 104 (do you see why?). Your code should be very similar, but should target the other two keys ('Sloth' and 'Burmese Python').