Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,704 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,704 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.