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

Anne Manning
Anne Manning
5,415 Points

I keep getting message OOPS task on is no longer passing?

I cant seem to get past this section to continue on with the training. I believe that my code is correct. Any help/direction will be appreciated.

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

3 Answers

Haider Ali
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Haider Ali
Python Development Techdegree Graduate 24,724 Points

Hi there Anne, in python, blocks of code are specified by indentation. If you were using JavaScript, you would put curly braces around a block of code. However, in python, blocks of code are specified by just using indentation so python knows which code belongs to what. In your code, the else block is indented inside the if block and shouldn't be. If an else and if are part of the same conditional statement, they should be indented to the same level. Here is how it should look:

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

If you have any other questions, please leave a comment.

Thanks,

Haider

Anne Manning
Anne Manning
5,415 Points

Thank you very much. I forgot the indentation!

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,728 Points

Hey Anne,

While the code is correct, the indentation is off. Python is indent specific when it comes to programming syntax. Right now, the way you have it written, the else clause is inside the if statement. You want the else to be on its own. Just remove the indent on your else clause.

Hope that helps. Keep Coding. :dizzy:

Anne Manning
Anne Manning
5,415 Points

WooHoo! That worked!!! Thank you very much!!

Levis Vazquez
Levis Vazquez
961 Points

Thanks for your comment, I was stuck here.

admitted = None

if age >= 13:

admitted = True

else:

admitted = False