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 trialErik Luo
3,810 Pointsunexpected indent (<string>, line 1). how to fix it?
I don't know what's wrong with this code.
if admitted = None:
age < 13
else age >= 13
3 Answers
David Bath
25,940 PointsI don't think you are using correct logic. The condition is "if age is 13 or more", so that is your if statement right there. So
admitted = False
if age >= 13:
Then what? Then if that condition passes, you need to set admitted to True:
admitted = False
if age >= 13:
admitted = True
Erik Luo
3,810 PointsRight, thank you, that worked. Is confusing because it says you can't change the first line, and the first line is admitted = None.
David Bath
25,940 PointsWell, None and False are both considered "falsey", so it should work just as well if you used None. But you also need to use the correct logic for the rest of it.
Erik Luo
3,810 PointsThe next task I got is to "add an else to your if. In the else, set admitted to False." I added "else admitted = False" and it tells me that task 1 is no longer passing. Why is that?
Yalamber subba
10,943 Pointsadmitted = None if age >= 13: admitted = True
David Bath
25,940 PointsWell, I'd have to see your code, but make sure you're putting a colon after "else".
Erik Luo
3,810 PointsErik Luo
3,810 PointsThe challenge task is: I'm going to create a variable named age. I need you to make an if condition that sets admitted to True if age is 13 or more.