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 Introducing Dictionaries Introducing Dictionaries Creating a Dictionary

Paul C
Paul C
2,668 Points

Not 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
Josh Keenan
19,652 Points

I 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.

Paul C
Paul C
2,668 Points

Ahh I see. Must not have been indexed by Google yet because I did search for it! Thanks for the help Josh!

Håvard Hytten
Håvard Hytten
6,239 Points

My 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
Michael McGill
2,085 Points

as 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.