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

Python

Conditional 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
MOD
Chris Freeman
Treehouse Moderator 68,468 Points

The challenge grader sets the value of age. You need to comment out your assignment line age = 14

Thank you Chris, it worked.

It works, but I don't understand why it have to comment out? can you explain to me, please.

Chris Freeman
Chris Freeman
Treehouse Moderator 68,468 Points

The code challenge is graded by a program that needs to set age to various values, then execute your code. If your code sets age it 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.

Oh, I see. Thank you so much!

admitted = None

if age >= 13:

admitted = True

else:

admitted = False

why 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)

Secondly.. 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.

i got it Mr. Chris Freeman Thank you so much :)