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 trialPaul C
2,668 PointsNot sure what I'm doing wrong here. Assigning value of a dict key to a new variable.
"On an empty line beneath the existing code, create a variable called topic and assign to this variable the value of the topic key in the student dictionary. "
This is my answer:
student = {'name': 'Paul', 'topic': 'python'}
topic = student['topic']
First line was correct in having us make the dictionary from part one of this challenge. Am I misreading the question here?
3 Answers
Josh Keenan
20,315 PointsI had the same issue, the topic needs to be 'Python' with a capital P to pass the second challenge for some reason, your code is fine.
Håvard Hytten
6,239 PointsMy code looked alot like yours and I had some trouble with this challenge aswell. My issue with this challenge was that i couldnt have apostrophe's surrounding topic in the brackets. Instead you need to use quotations marks. I wrote this code which passed:
student = {'name':'Spencer', 'topic':'python'} topic = student["topic"]
Michael McGill
2,085 Pointsas of September 11 2019, in this exercise, you no longer need python spelt with a capital 'P' as before. I read this thread when I was struggling with it and, changed my python to Python because I remembered the same thing happened on a previous challenge exercise. That was before I had figured out the correct code. But by the time my code was correct, no matter what I did, it wouldn't pass me. I was sure my code was correct. Well when I changed it back to lower case 'p' I passed it. Someone needs to delete those posts so they don't keep tripping people up.
Josh Keenan
20,315 PointsJosh Keenan
20,315 Pointshttps://teamtreehouse.com/community/issue-with-challenge
Paul C
2,668 PointsPaul C
2,668 PointsAhh I see. Must not have been indexed by Google yet because I did search for it! Thanks for the help Josh!