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

Erik Luo
Erik Luo
3,810 Points

unexpected indent (<string>, line 1). how to fix it?

I don't know what's wrong with this code.

conditions.py
if admitted = None:
    age < 13 
    else age >= 13
Erik Luo
Erik Luo
3,810 Points

The challenge task is: I'm going to create a variable named age. I need you to make an if condition that sets admitted to True if age is 13 or more.

3 Answers

David Bath
David Bath
25,940 Points

I don't think you are using correct logic. The condition is "if age is 13 or more", so that is your if statement right there. So

admitted = False
if age >= 13:

Then what? Then if that condition passes, you need to set admitted to True:

admitted = False
if age >= 13:
    admitted = True
Erik Luo
Erik Luo
3,810 Points

Right, thank you, that worked. Is confusing because it says you can't change the first line, and the first line is admitted = None.

David Bath
David Bath
25,940 Points

Well, None and False are both considered "falsey", so it should work just as well if you used None. But you also need to use the correct logic for the rest of it.

Erik Luo
Erik Luo
3,810 Points

The next task I got is to "add an else to your if. In the else, set admitted to False." I added "else admitted = False" and it tells me that task 1 is no longer passing. Why is that?

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

David Bath
David Bath
25,940 Points

Well, I'd have to see your code, but make sure you're putting a colon after "else".