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

Joshua Clark
Joshua Clark
6,186 Points

Task 2 is not letting me use the "else" Why?

My code is shown below. I cannot understand why it will not pass. I have checked my indentations. Please help. I've watched numerous videos and have read many resources regarding this and still can't get it to pass.

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

1 Answer

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,735 Points

The error message says "Bummer! Don't set the age variable, I'll do that for you."

They're going to take your code and run it against some test cases, where the age variable might be low or high.

Joshua Clark
Joshua Clark
6,186 Points

Thanks Brendan. I'm a little confused because the question is "OK, one more. Add an else to your if. In the else, set admitted to False."Maybe I'm not understanding it correctly. Even if I could remove the "if" from my code then it tells me that "task 1 is no longer passing" I'm still stumped.

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,735 Points

You need to get rid of this line:

age = 13

and keep everything else.

Task 1 was to add the if block. If you remove that, then Task 1 will no longer be passing.

Joshua Clark
Joshua Clark
6,186 Points

Thank you Brendan, it worked! I removed the line with the age variable. I don't know why I didn't understand what the statement in the question meant (regarding the course already setting the age variable). I just didn't read the instructions correctly.