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

Task 2

lines 1-3 task 1 passes, when lines 4-5 added during task 2 error occurs saying "task 1 no longer passing. Tried a few variations to the code and can't get it to work. task 1 "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." Task 2 "OK, one more. Add an else to your if. In the else, set admitted to False."

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

2 Answers

Kyler Smith
Kyler Smith
10,110 Points

Python's language was created for ease and readability. Indentation is very specific and required for everything. With that being said, your else clause is indented too far in. Try removing the tab for only this line.

admitted = None
if age >= 13:
    admitted = 'True'
    else: # Unindented is causing the error here
    admitted = 'False'
admitted = None
if age >= 13:
    admitted = 'True'
else: 
    admitted = 'False'
admitted= None

if age >= 13:
   admitted = True
else:
    admitted = False        # Notice true and false are boolean values not strings, remove the quotes around them