Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


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):
    print("Added {}. Lis now has {} items.".format(new_item, len(shopping_list))

while True:
    new_item = input("> ")

    if new_item == 'DONE':

    if new_item == 'SHOW':
        for item_now in shopping_list:

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


print("Here's your todolist:")

for item in shopping_list:

[MOD: fixed formatting -cf]

Steven Parker
Steven Parker
216,149 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
216,149 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 ')'