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 trialNikhil Alexander
1,444 Pointsim getting a syntax error which is saying that index += 1 is an invalid syntax
index += 1 is giving me a syntax error please help me out
1 Answer
Steven Parker
231,248 PointsHave you previously created "index" and given it a value? If not, this code would cause a syntax error because it's trying to add one to something that doesn't exist yet.
If that's not the problem, you might need to show the whole program. If it's short, you can post it (with proper formatting). Even better, make a snapshot of your workspace and post the link to it here.
Nikhil Alexander
1,444 PointsNikhil Alexander
1,444 Pointssorry i forgot to attach my script... i have created index...can u please help me out??
Steven Parker
231,248 PointsSteven Parker
231,248 PointsThe issue is on the previous line:
print("{}. {}".format(index, item)
The parentheses are unbalanced — there are two opens but only one closing parenthesis.
Nikhil Alexander
1,444 PointsNikhil Alexander
1,444 Pointsthank you for the help Steven ... i also rectified all my other mistakes in the script ... thank you once again ...