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 trialDouglas Ngwenya
3,132 PointsPlease 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.
player = {"name": "Douglas", "remaining_lives": 3, "levels": [1, 2, 3, 4], "items" = {"pork", 5"}}
3 Answers
Chris Freeman
Treehouse Moderator 68,457 PointsThere are two typos:
change = to : after
"items"
change , to : after
"pork"
Douglas Ngwenya
3,132 PointsThanks Chris!
Wilfried Allico
2,495 PointsHello. 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
Treehouse Moderator 68,457 PointsWilfried, 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
10,448 PointsThe 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.
Chris Freeman
Treehouse Moderator 68,457 PointsPromoted to Answer.
Douglas Ngwenya
3,132 PointsThanks Matthew. After either removing the double " or adding another one before 5 it wont pass
Dingindlela Mhlanga
3,298 Pointsplayer = {"name": "Douglas", "remaining_lives": 3, "levels": [1, 2, 3, 4], "items" = {"pork", 5}}
Douglas Ngwenya
3,132 PointsDouglas Ngwenya
3,132 Pointsit still fails even if like this:
player = {"name": "Douglas", "remaining_lives": 3, "levels": [1, 2, 3, 4], "items" = {"pork", 5}}