Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Collections (2016, retired 2019) Dictionaries Dictionary Basics

George Lugo
seal-mask
.a{fill-rule:evenodd;}techdegree
George Lugo
Python Web Development Techdegree Student 922 Points

why is my question wrong?

player = ["name": "John", "remaining_lives":3] print["name","remaining_lives"]

dicts.py
player = ["name": "John", "remaining_lives":3]
print["name","remaining_lives"]

2 Answers

Stuart Wright
Stuart Wright
41,118 Points

That is not the correct notation for a dictionary. You need to use {} rather than [] to create a dictionary.

Your print statement is also wrong in a couple of ways - the thing you want to print goes inside () rather than [], and you haven't correctly pointed to the dictionary values that you want to.

I would recommend going back and re-watching the video to be honest to gain a stronger understanding of dictionaries.

As Stuart mentioned, dictionaries in Python are made like this:

my_dict = {"key1": "value1", "key2":"value2"}

I'm not 100% sure what you're supposed to print but by looking at your attempt, I'd say you're printing the values for each key. To print, you first need to access the dictionary inside () like so:

print(my_dict)

To access a specific value, you need to access the dictionary and then the key for the value like this:

my_dict["key1"]

Now, see if you can put those two together to print what you want from your dictionary!