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 trialRoland Vas
1,967 Points2nd Challenge Task if else Admitted question giving me trouble
This is my code, I believe it is correct, unless I'm not seeing something through correctly or I missed a rule on the if else conditions.
admitted = None
age = 14 if age >= 13: admitted = True else: admitted = False
The first part of the challenge i get a correct answer, on the 2nd part though I'm getting a Bummer! ' admitted' is not False message... if i change the age then the message is reffering to the first task not passing. Please help!
admitted = None
age = 14
if age >=13:
admitted = True
else:
admitted = False
3 Answers
Steve Hunter
57,712 PointsThe variable age
is set by the challenge. Remove the line age = 14
else you'll overwrite the test setting it to less than 13. Hence, the expected result of False
is never stored in admitted
. The questions starts with I'm going to create a variable named age so you don't have to.
The code should look like:
admitted = None
if age >= 13:
admitted = True
else:
admitted = False
The challenge will run your code with age set to two values. If you change that value in the code, the test suite will assume, correctly, that your code isn't working as it expected.
I hope that makes sense.
Steve.
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.
admitted = None
if age >= 13:
admitted = True
Keep up the momentum!
Ary de Oliveira
28,298 PointsChallenge 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
Roland Vas
1,967 PointsRoland Vas
1,967 PointsThank you!
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsNo problem! Glad you got it fixed. :-)
Ary de Oliveira
28,298 PointsAry de Oliveira
28,298 PointsCool