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

Shopping list program error assignment

//What is wrong with my code, I am not receiving an output of items when I input them??//

shopping_list = []

print("What do you want to pick up from the store") print("Enter 'DONE' to stop adding items to the list")

while True:

new_item = input("> ")

if new_item == 'DONE': break

shopping_list.append(new_item)
print("Added! List has {} items.".format(len(shopping_list)))

print("Here is your list:") for item in shopping_list: print(item)

2 Answers

Hi Simran here's the code:

shopping_list = list()

print("What would you like to pick up at the store ? ") print("Enter 'DONE' to stop adding items to the list. ")

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's your list: ")

for item in shopping_list: print(', '.join(shopping_list) + '.')

//This is the error I am receiving now. How do I fix it??//

File "shopping_list.py", line 12
shopping_list.append(new_item) print("Added! List has {} items.".format(len(shopping_list)) continue
^
SyntaxError: invalid syntax

Looking at your last post:

Simran Bansari 2d ago //This is the error I am receiving now. How do I fix it??//

File "shopping_list.py", line 12 shopping_list.append(new_item) print("Added! List has {} items.".format(len(shopping_list)) continue ^ SyntaxError: invalid syntax

the line:

print("Added! List has {} items.".format(len(shopping_list))

is missing one more parenthesis to close the print method.

print("blah {} blah.".format(len(variable)))

Also, try to notate that the carrot "^" symbol in the error received points to where the issue is taking place. In this case the carrot "^" should be pointing to a space after the two parenthesis at the end of len(shopping_list))