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
Michael Rawlinson
1,507 PointsError - Python
How do I fix this and how do I paste my code into this window withought it looking to messy?
< File "function_list.py", line 27, in <module>
add_to(new_item)
File "function_list.py", line 9, in add_to
shopping_list.append(item)
AttributeError: 'dict' object has no attribute 'append' >
1 Answer
Richard Lu
20,185 PointsHi Michael,
I'm not sure which video you're following, but It seems as though your variable shopping_list is a dictionary, and to add values onto a dictionary you could use subscript notation:
a = {
"michael": 100,
"steve": 90,
"jake": 89
}
# subscript notation
a["rich"] = 85
a["dan"] = 80
I hope this helps :)