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

Fred Huelsbeck
Fred Huelsbeck
1,344 Points

Test fails for second task.

The task states: "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."

My code is: student = {'name':'2', 'topic':'Python'} topic = (student['topic'])

When I check the code I get: Bummer: Whoops, looks like the topic variable is assigned to the wrong value. Check that the topic key has the correct value in the student dictionary, and check that you're accessing this value correctly.

I created a script, but changed the code a bit as a test: student = {'name':'2', 'topic':'Python'} the_topic = (student['topic']) print(the_topic)

When I run this script, it returns "Python", which I believe is the correct result. What am I missing?

creating_dictionaries.py
student = {'name':'2', 'topic':'Python'}
topic = (student['topic'])

2 Answers

Mark Sebeck
MOD
Mark Sebeck
Treehouse Moderator 38,304 Points

Hi Fred Huelsbeck . Notice in the instructions for task 1, python is not capitalized.

"Create a dictionary with the following key value pairs: 1) key: 'name', value: '', 2) key: 'topic', value: 'python'. Assign this dictionary to a variable called student."

Hope this helps :)

Fred Huelsbeck
Fred Huelsbeck
1,344 Points

That was the problem. With that said, the first task passes if the p in python is upper or lower. The two tasks should be consistent.