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 trialAlex Potham
860 PointsChallenge Task 2 of 2 OK, one more. Add an else to your if. In the else, set admitted to False.
i'v been stuck on this for days now. and its not working. please please help!
admitted = None
if age >= 13:
admitted = 'true'
else:
admitted = 'false'
2 Answers
Chris Freeman
Treehouse Moderator 68,441 Pointsadmitted
needs to be set to the built-in values True
and False
not strings:
admitted = None
if age >= 13:
admitted = True
else:
admitted = False
Alex Potham
860 Pointsthankyou for your help Chris
Alex Potham
860 PointsAlex Potham
860 Pointsthanks for your speedy response chris but the only way task 1 will work is if i put true into a string. it comes up with 'true' not defined otherwise.
Alex Potham
860 PointsAlex Potham
860 Pointsooooooh wait i have got it!! capital letters in 'True' and 'false'
A X
12,842 PointsA X
12,842 PointsChris, Why do we delete/comment out the
age =
part of the first part of the challenge here? How does the if/else know what to test against without it?Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsAbbymann, the challenge checker sets up a context for the code to run in. This lets it try many values for
age
to test each branch of flow through the code.