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 trialNasir Khalid
Python Web Development Techdegree Student 4,779 Pointsdictionary-basics challenge
Hi. I can not pass this challenge for some reason. I am stuck on the last task. Can someone point out my mistake? Thanks! I created a dictionary for the 'items' but it is still not passing.
player={'name':'Donald Mcintyre','remaining_lives':'3','levels':[1,2,3,4],'items':{'ak-47':1,'jack_knife':4}}
player={'name':'Donald Mcintyre','remaining_lives':'3','levels':[1,2,3,4],'items':{'ak-47':1,'jack_knife':4}}
2 Answers
Jialong Zhang
9,821 PointsDo you have the original question? For example, let player = ["name": "Donald Mcintyre", "remaining_lives": "3"] this is [String: String] type or something like ["egg": 1, "apple": 2] this is [String: Int] Your code: player = {"name": "Donald Mcintyre","remaining_lives": 3} error !! first type[String: String], second[String: Int]
Nasir Khalid
Python Web Development Techdegree Student 4,779 PointsOhh I get it now. Thank you so much ! :) I actually used the 3 in the quotes instead of using it as an integer Thanks a bunch my problem is solved :)
Nasir Khalid
Python Web Development Techdegree Student 4,779 PointsNasir Khalid
Python Web Development Techdegree Student 4,779 PointsI don't quite get what you mean by [string:string] and [string:int] because I thought we could put either a string or an integer in the value of an item in a dict? (string with a " " and int with a number eg 3 without the quotes) Well here's the question: Task_1 Make a dictionary named player and add two keys to it. The first key should be "name" and the value can be any string you want.
The second key should be "remaining_lives". Set this key's value to 3. Task_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.
I am able to do Task 1 but when I do Task 2 it says Task 1 is no longer passing :P Thanks for your help! :)