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 trialLydia French
574 Points"Add an else to your if. In the else, set admitted to False." I believe I did what it says.....
I think its right, but its not passing. A new set of eyes would be great.
admitted = None
age = 16
if age > 13:
admitted = True
else:
admitted = False
1 Answer
andren
28,558 PointsThere are two issues with your code:
You set the age variable to 16, that is not something the task asked you to do. And doing anything beyond the exact thing the task asks of you will often cause problems. In this case the age variable is defined and set by the challenge checker, by adding the variable yourself you override the value the challenge checker sets, which will cause your code to fail.
The else part of an if else statement has to be indented (spaced) to the same level as the if, indenting it to be inside the if statement like you have done is incorrect. Getting indentation right is vital when coding in Python.
Fixing those two issues produces this code:
admitted = None
if age > 13:
admitted = True
else:
admitted = False
Which will allow you to pass the challenge.