Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

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

3 Answers

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

Renato Guzman
Renato Guzman
47,690 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!

Michael Roberts
Michael Roberts
2,090 Points

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'}

"""