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

Another misleading question in my opinion

age is not defined yet and it says "i'm going to create a variable age" i need help

conditions.py
admitted = None
if age < 13:
    admitted == True

2 Answers

andren
andren
28,558 Points

When the code checker runs your code it will define the age variable before running your code. So even though you don't see age being declared within the code you can use it within the script, that's what the challenge means when it states it will create it for you.

The reason why your code fails is that:

  1. You check if age is less than 13, when the task asked you to check if age was greater than or equal to 13.

  2. You use == instead of =. == is used to compare two values, = is used to assign a value.

If you fix those two issues like this:

admitted = None
if age >= 13: # Check if age is greater or equal to 13
    admitted = True # Set admitted to True

Then you will be able to pass the first task.

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Samuel,

I'm not sure what you find misleading? The instructions clearly state what to do, and you have done it, except your code has one syntax error and one logic error.

  1. The instructions say to "assign" the value of True to admitted if the condition passes, but you are using a comparison operator not an assignment operator.
  2. The challenge says to check if the age is 13 or greater, but you are checking to see if age is less than 13.

Just fix those two things up and your code will pass.

Keep Coding! :) :dizzy: