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

Create a dictionary with the following key value pairs: 1) key: 'name', value: '', 2) key: 'topic', value: 'python'.

need help with the above

dict{key:value, key: value}
>>>demo_dict={student: 'kagiso' , course: 'python' }

3 Answers

student = {'name':'2', 'topic': 'python'}

Renato Guzman
Renato Guzman
51,263 Points

Hi, I think you should take care of the quotes. Unlike JavaScript, Python dictionary keys needs to be quoted if they are strings.

The challenge states that you should create key value pairs ('name' and 'topic') in your answers you are settings as keys student and course. If you change your key names then you are on good track, just one more thing.

Note that the challenge indicated that you must assign the dictionary to a variable student and in your solution you are assign the dictionary to the variable demo_dict.

Hope it helps!

I personally feel this particular test was poorly worded or defined.
For others who got stuck on this:


{"key": "value", "key": "value"}
student = {'name':'2', 'topic': 'python'}