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.

Python Python Collections (2016, retired 2019) Lists Removing Items From A List

SyntaxError: invalid syntax when adding the try/except

Code was running just fine till I added this code.

def remove_from_list():
    show_list()
    what_to_remove = input("What would you like to remove?\n> "
    try:
        shopping_list.remove(what_to_remove)
    except ValueError:
        pass
    show_list()

Now when I first opened this file I found that I needed to remove alot of spaces and add tabs because I was getting alot of indentation errors, but the code was running correctly until I added the function. I have the indentation guides turned on to help with the issue I was having with the indentation errors, but I don't think I've gotten the syntax wrong here.

Have I gotten something wrong here...?

Shreyas Papinwar
Shreyas Papinwar
2,371 Points

On line 3 you didn't close input().

1 Answer

Shreyas Papinwar
Shreyas Papinwar
2,371 Points

On line 3 you didn't close input().

GOOD LUCK!