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

Please help, what is wrong with my code?

Challenge Task 2 of 2

OK, one more step.

Now add a "levels" key. It should be a list with the values 1, 2, 3, and 4 in it.

And, lastly, add an "items" key. This key's value should be another dictionary. Give it at least one key and value, but they can be anything you want.

dicts.py
player = {"name": "Douglas", "remaining_lives": 3, "levels": [1, 2, 3, 4], "items" = {"pork", 5"}}

it still fails even if like this:

player = {"name": "Douglas", "remaining_lives": 3, "levels": [1, 2, 3, 4], "items" = {"pork", 5}}

3 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

There are two typos:

  • change = to : after "items"

  • change , to : after "pork"

Thanks Chris!

Hello. There is something that I don't understand in the challenge. If it asked to add a list in the dictionary, shouldn't it the "levels" key have an equal sign for the values 1,2,3,4? I hope I made my question clear lol. Thank you.

Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

Wilfried, all dictionary assignments should be of the form key:object. In this case, the key is ”levels” and the object is the list [1, 2, 3, 4].

Matthew Carroll
Matthew Carroll
10,448 Points

The syntax highlighting here shows the error quite well, you have an extra quotation mark, or a missing one after the final '5' in your items key.

Thanks Matthew. After either removing the double " or adding another one before 5 it wont pass

player = {"name": "Douglas", "remaining_lives": 3, "levels": [1, 2, 3, 4], "items" = {"pork", 5}}