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 Update and Mutate Dictionaries

Adem Gun
Adem Gun
1,511 Points

Can't add text to dictionary via: course['text here']= text

Here's my code which isn't working. It works when I replace volvo with a number:

>>> course = {'teacher':'Ashley', 'title':'Introducing Dictionaries', 'level':'Beginner'} 
>>> course['cars']= volvo                                                                 
Traceback (most recent call last):                                                        
File "<stdin>", line 1, in <module>                                                     
NameError: name 'volvo' is not defined

2 Answers

Megan Amendola
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Megan Amendola
Treehouse Teacher

Hi, Adem!

Your code isn't working because volvo is missing the quotations around it to make it a string: 'volvo'. Right now Python thinks it is a variable since it doesn't have the quotations and is saying that you haven't defined this variable yet.

Adem Gun
Adem Gun
1,511 Points

Ah thank you!