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 Python Basics (2015) Logic in Python Conditional Value

Why is this code not accepted?

Why is this code not accepted for the challenge? It works fine on my python box.

admitted = None age = 15

if age > 12: admitted = True print(admitted) else: admitted = False print(admitted)

conditions.py
admitted = None
age = 15

if age  > 12: 
    admitted = True
    print(admitted)
else:
    admitted = False
    print(admitted)

1 Answer

andren
andren
28,558 Points

The reason is stated pretty clearly by the error message your code produces:

Don't set the age variable, I'll do that for you.

For this challenge the age variable is set by the code checker itself, you are not meant to define a value for it yourself. Doing so overrides the value the code checker uses which screws up it's ability to verify that your code actually functions correctly.

If you remove the age variable declaration like this:

admitted = None

if age  > 12: 
    admitted = True
    print(admitted)
else:
    admitted = False
    print(admitted)

Then your code works.