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

Kevin Hills
Kevin Hills
766 Points

Task One error message

When I am doing review questions, when i answer the first step correctly and go onto the next step I am told my Task one is no longer passing even though I have not changed it. What is happening?

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

2 Answers

Michael Hulet
Michael Hulet
47,913 Points

Task one is no longer passing because you introduced a syntax error. Remember that Python knows what code goes with what other code by how far it's indented. Right now, Python sees an if statement with a valid line right afterwards, but then it sees an else statement and a line in that block that's entirely detached from everything else, with no if statement before it. Make sure that the else block is indented the same amount as the if statement it goes with, and that the code within the 2 blocks are indented the same amount as each other, too.

Also, note that code that looks like this isn't really good in a real program. If you're making an actual project outside of Treehouse, if you ever see yourself just assigning a boolean variable based on some comparison, it's better to assign the boolean directly from the variable, like this:

admitted = age >= 13
Kevin Hills
Kevin Hills
766 Points

I understand now. Thank you!