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'. Ass

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.

creating_dictionaries.py
student = {'name':''}
student = {'topic':'python'}
print(student())
Gregory St. Clair
Gregory St. Clair
Courses Plus Student 2,001 Points

Hey there :)

You've got a few things sideways here.

first, you assigned student twice, which means student in this case is only a dictionary that contains the topic:python key value pair - because you assigned over it in your code.

What you are looking to do is this: student = { 'name':'', 'topic':'python' }

Do you see how both key value pairs are in the same dictionary, separated by a comma? Next, to call it: print(student)

since student is already declared.

2 Answers

Put it all under the student variable. By the way for the value for 'name', it wants you to make " the value Like this:

student = {'name': '"', 'topic' : 'python'}
Greg Heffley
Greg Heffley
6,371 Points
student = {
    "name" : "",
    "topic" : "python"
}

You created a dictionary and then reassigned it with a new dictionary.

Just put them both into the same variable.

Instead of calling print students like a function. ex (your print function), call it like a variable. ex (print(student))

In this example, you do not even need the print function.