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 trialRandy Varley
1,533 PointsMy conditional code is good. I tried it in the REPL on my own computer, but the question is still failing.
The first question says write a conditional if that sets var admitted to True if age is >= 13. I did that and it work. Question 2 says add an else that sets admitted to False if age isn't >= 13. I did this. It works in my REPL, but it's still failing. If I set the age to > 13, it says 'now question one is failing. If I set it to 12, it still fails.
admitted = None
age = 13
if age >= 13:
admitted = True
else:
admitted = False
2 Answers
Tobias Helmrich
31,603 PointsHey Randy,
this problem occurs because you don't have to set the age variable yourself. This will be done automatically when the challenge is evaluated. Right now it always evaluates to True and that's probably why the challenge fails.
So this should work:
admitted = None
if age >= 13:
admitted = True
else:
admitted = False
Good luck! :)
Randy Varley
1,533 PointsThanks. That fixed the issue. It's odd that the question states 'I'm going to have you create a variable named age . . .' if they don't expect the user to declare the variable.
Tobias Helmrich
31,603 PointsMy challenge description says "I'm going to create a variable named age.".