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

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,728 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,858 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