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 trial
Mauricio Rey
4,331 PointsConditional Value
To this question, I reproduced it on my console and it works, but it is not working on workspaces.
OK, one more. Add an else to your if. In the else, set admitted to False.
admitted = None
age = 14
if age >= 13:
admitted = True
else:
admitted = False
The first tasks passes, as age is True, but the second task is giving me an error saying admitted is not false. When I change age to < 13, the first task doesn't pass. :)
[MOD: added ```python markdown formatting -cf]
4 Answers
Chris Freeman
Treehouse Moderator 68,468 PointsThe challenge grader sets the value of age. You need to comment out your assignment line age = 14
Ary de Oliveira
Courses Plus Student 28,304 Pointsadmitted = None
if age >= 13:
admitted = True
else:
admitted = False
Taha El Azezy
Python Development Techdegree Student 2,506 Pointswhy it worked in that way, i did this and it does not work
admitted = False
age = 13
if age >= 13:
print('True')
else:
print(admitted)
Chris Freeman
Treehouse Moderator 68,468 PointsYou need to comment out the line age = 13
doctacloak
12,202 PointsSecondly.. why are you printing it out? You don't need to print anything, all you need to do is declare the value of the variable as True or False.
Taha El Azezy
Python Development Techdegree Student 2,506 Pointsi got it Mr. Chris Freeman Thank you so much :)
Mauricio Rey
4,331 PointsMauricio Rey
4,331 PointsThank you Chris, it worked.
Siyuan Welch
3,025 PointsSiyuan Welch
3,025 PointsIt works, but I don't understand why it have to comment out? can you explain to me, please.
Chris Freeman
Treehouse Moderator 68,468 PointsChris Freeman
Treehouse Moderator 68,468 PointsThe code challenge is graded by a program that needs to set
ageto various values, then execute your code. If your code setsageit overwrites the grader's value causing the code to get unexpected results from the grader's perspective.It's not a syntax issue. It's just for the grader.
Siyuan Welch
3,025 PointsSiyuan Welch
3,025 PointsOh, I see. Thank you so much!