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 Python Basics (2015) Shopping List App Shopping List Introduction

my code is not working

make a list to hold our items

shopping_list = {}

print out instructions on how to use the app

print("What should we pick up at the store?") print ("Enter 'DONE' to stop the adding items.")

while True: #ask for new items new_item = input("> ")

# be able to quit the app
if new_item == 'DONE':
    break

#add new items to our list
shopping_list.append(new_item)

print out the list

print("Here's your list:")

for item in shopping_list: print(item)

what's wrong with the code!!!! it keeps giving me an AttributeError at the shopping_list.append saying 'dict' object has no attribute 'append' what does this mean. plz help thank you

2 Answers

Yipeng Wang
Yipeng Wang
3,211 Points

Hi Ayub

Here is it , this was how you define the list shopping_list = {}, "{}" defines a dictionary rather than a "list" , that's why you got a AttributeError , a dictionary variable does not have the append() function you should change it to shopping_list = []

BR/Yipeng

Yes Thanks You Very Much That makes sense!