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 trialAndrej Pajenk
1,087 PointsI'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
i don t know
admitted = None
age = 13
if age >= 13:
admitted = True
5 Answers
Steve Hunter
57,712 PointsHi Andrej,
The challenge sets the variable value; you have then overriden it. Delete age = 13
and your code looks OK.
I'll check, but that's one issue - don't override the tests behind the scenes.
[EDIT:] Yes, your code is fine without the age
variable. As the question says, "I'm going to create a variable named age". The compiler will run two tests, one with age
set to under 13 and one with it set to over. One will fail because you have hard-coded age
to be 13, overriding the challenge tests.
I hope that makes sense.
Steve.
Tara Edwards
6,521 PointsAlso, put a colon after the if statement.
Steve Hunter
57,712 PointsGood spot; missed that!
Ary de Oliveira
28,298 PointsChallenge Task 1 of 2
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.
Well Done! Ary.
admitted = None
if age >= 13:
admitted = True
Challenge Task 2 of 2
OK, one more. Add an else to your if. In the else, set admitted to False.
admitted = None
if age >= 13:
admitted = True
else:
admitted = False
Loren Moyer
306 Pointsnone of these work for me
Steve Hunter
57,712 PointsCan you post your code?
nathanielcusano
9,808 Pointsadmitted= None
if age >= 13:
admitted = True
Dimitri McDaniel
8,718 PointsDimitri McDaniel
8,718 Pointsadmitted = None if age >= 13: admitted = True
make sure to capitalize your 'true'