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 asked about If and else, but the else is not working even WITH the colon on else. I don't know what I am doing wrong.

I am on the second task for this, and it is not letting me pass. I don't understand why this is happening. Please help.

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

2 Answers

Steven Parker
Steven Parker
231,261 Points

You did a little too much.

The challenge said "I'm going to create a variable named age." It only wanted you to create the code that tests it.

But if you create a variable named age yourself, it prevents the value that the challenge supplies during testing from being used.

The challenge also says, "I need you to make an if condition that sets admitted to True if age is 13 or more.", but your test checks if age is 13 or less.

I'll bet you can do it now without an explicit spoiler.

Reyam Marcos
PLUS
Reyam Marcos
Courses Plus Student 10,367 Points

in this challenge you dont have to create a variable age, since the task says that he is the one whose going to create it, and the correct operator for greater than or equal to is >= , <= is less than or equal to

admitted = None

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

hope it helps