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 trialSebastian Giliberto
1,809 PointsWhat is wrong here?
shopping_list = list()
print("What would you like from the store? ")
print("Enter 'DONE' to stop adding things. ")
while True:
new_item = input("> ")
if new_item == 'DONE':
break
shopping_list.append(new.item)
print("Added! List has {} items.".format(len(shopping_list)))
continue
print("Here is your list: ")
for item in shopping_list:
print(item)
When ever I run the script it doesn't say Added! List has _ items in it after adding a item, or it doesn't say what I have in the list after.
1 Answer
Chris Freeman
Treehouse Moderator 68,428 PointsA few things to correct:
shopping_list = list()
print("What would you like from the store? ")
print("Enter 'DONE' to stop adding things. ")
while True:
new_item = input("> ")
if new_item == 'DONE':
break
# This section outdented (was aligned to breack statement above)
shopping_list.append(new_item) #<-- Changed to new_item from new.item
print("Added! List has {} items.".format(len(shopping_list)))
# continue # <-- continue not needed as last command in while block
print("Here is your list: ")
for item in shopping_list:
print(item)