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

I'm going to create a variable named age. I need you to make an if condition that sets admitted to True if age is 13

i don t know

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

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

make sure to capitalize your 'true'

5 Answers

Hi Andrej,

The challenge sets the variable value; you have then overriden it. Delete age = 13 and your code looks OK.

I'll check, but that's one issue - don't override the tests behind the scenes.

[EDIT:] Yes, your code is fine without the age variable. As the question says, "I'm going to create a variable named age". The compiler will run two tests, one with age set to under 13 and one with it set to over. One will fail because you have hard-coded age to be 13, overriding the challenge tests.

I hope that makes sense.

Steve.

Tara Edwards
Tara Edwards
6,521 Points

Also, put a colon after the if statement.

Good spot; missed that! :+1:

Challenge Task 1 of 2

I'm going to create a variable named age. I need you to make an if condition that sets admitted to True if age is 13 or more.

Well Done! Ary.

admitted = None

if age >= 13:
    admitted = True 

Challenge Task 2 of 2

OK, one more. Add an else to your if. In the else, set admitted to False.

admitted = None

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

none of these work for me

Can you post your code?

admitted= None

if age >= 13:
   admitted = True