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

Key Management - Second Challenge...

I am having some trouble with this exercise:

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.

Below is the code that I've tried to put input - I would appreciate any assistance that someone could provide - Thank you...

dicts.py
player = {"name": "Melanie Iglesias", "remaining_lives": 3, "levels": [1,2,3,4]}
player2 = {"items": "backpack"}

4 Answers

Jose Soto
Jose Soto
23,407 Points

The items key needs to be part of the player value. Also, the items key should have a value of a dictionary. It is currently set to a string of "backpack".

I tried adding on to player, but I keep getting the "Task 1 is no longer passing" message:

player = {"name": "Melanie Iglesias", "remaining_lives": 3, "items": {"backpack": "laptop"}
Jose Soto
Jose Soto
23,407 Points

You are missing a closing } Also, don't forget to include "levels": [1,2,3,4]

I'll take a closer look in the morning - Thanks for your help so far, Jose - I appreciate it...

Thanks a bunch, Jose - I passed the challenge - Thank you... P :)

Peter Rzepka
Peter Rzepka
4,118 Points
this passes the challenge also:
player = {"name": "Kenneth", "remaining_lives": 3, "levels": [1,2,3,4], "items": dict([["newkey", "newvalue"]])}