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 trialANDY VAN DEN BOS
2,330 Pointsinvalid syntax (<string>, line 13). But I don' t have a line 13?
I am stuck on this code challenge because of this error message invalid syntax (<string>, line 13). I only see 8 lines so I am not sure how I can have a problem with line 13.
Furthermore I thought my code was pretty straight forward.
What am I missing here?
time = 15
store_open = None
store_hours = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
if time in store_hours:
store_open = True
else:
store_open = False
3 Answers
Jennifer Nordell
Treehouse TeacherHi there! You're actually doing really well here, and your logic is spot on. The Bummer! message is a little confusing, I know. But the problem here is indentation. Your else
block should match up with your if
block. If I copy/paste your code in the challenge and adjust the indentation, it passes.
Hope this helps!
Chris Freeman
Treehouse Moderator 68,441 PointsThat is an unusual error message. Tagging Kenneth Love to check on why "<string>, line 13
" is printed.
As for your error, The else
statement is indented too far. It should align with the if
statement. Re-indent the other lines as needed.
ANDY VAN DEN BOS
2,330 PointsThank you Chris.
Kenneth Love
Treehouse Guest TeacherThe <string>, line 13
thing is because I'm running your code explicitly in my test and I happen to be running it at line 13. Your code is inside of a giant string when I run it, so...error in a string on line 13. Sadly I can't get any more information from there because it's a syntax error, like Jennifer Nordell pointed out.
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsSo quick!! Good job Jennifer!!!
ANDY VAN DEN BOS
2,330 PointsANDY VAN DEN BOS
2,330 PointsThank you Jennifer, that fixed the problem.