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!