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

invalid syntax.

It says that the "invalid syntax" is by the while True satement. Thanks for helping out.

shopping_list = []

print("Add your things to your todo list!")
print("When you are done typ 'DONE' in caps.")

def add_to_list(new_item):
    shopping_list.append(new_item)
    print("Added {}. Lis now has {} items.".format(new_item, len(shopping_list))

while True:
    new_item = input("> ")

    if new_item == 'DONE':
        break

    if new_item == 'SHOW':
        for item_now in shopping_list:
            print(item_now)

    if new_item == 'HELP':
        print("help menu")
          add_to_list(new_item)


    shopping_list.append(new_item)

print("Here's your todolist:")

for item in shopping_list:
    print(item)

[MOD: fixed formatting -cf]

Steven Parker
Steven Parker
231,269 Points

Python is nearly impossible to analyze without proper blockquoting. Be sure you have a blank line before the first set of accents (```), and be sure the lines with the accents are on lines by themselves.

P.S. I revised this comment and added the nearly since I managed to find it anyway! See the answer below.

1 Answer

Steven Parker
Steven Parker
231,269 Points

This was tough to find because of the blockquoting problem, but it looks like you have mismatched parentheses in the first print statement. Here it is fixed:

    print("Added {}. List now has {} items.".format(new_item, len(shopping_list))) # <- added ')'