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

if else wtf?

What is wrong with this. When I click on the check work. I receive the message with this content "Don't set the age variable, I'll do that for you.". I am confused again.

conditions.py
admitted = None
age = 21
if age > 13:
    admitted = True
else:
    admitted = False

1 Answer

andren
andren
28,558 Points

There is nothing technically wrong with your code, your code would run fine in a normal Python environment, but for the challenges that Treehouse sets up they sometime will define code for you automatically so that they have more control over how your program functions, which makes it easier for them to check that it works as intended.

For this challenge Treehouse creates an age variable for you automatically, it is not visible in your script but it is accessible within it, which is why they ask you not to define an age variable yourself, as that overrides the variable they created for you.

Removing the age variable declaration like this:

admitted = None
if age > 13:
    admitted = True
else:
    admitted = False

Will result in code that will pass the challenge.