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 take three

This says "Syntax error" in line 26, and I can not understand why "else:" is a syntax error

here is the link

https://teamtreehouse.com/workspaces/31736632#

It says that else on line 26 is wrong but I already deleted it and it keeps telling me this.

try:
    position = abs(int(position))
except ValueError:
    position = None
if position is not None:
    shopping_list.insert(position-1, item)
else:
    shopping_list.append(new_item)

1 Answer

Your link doesn't seem to work.

However, from the info you gave I'm assuming that the function requires three parameters. You mention a syntax error with else: Is your indentation correct?

I copied the syntax error part of the code its the first else: