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

Challenge Task 2 of 2 OK, one more. Add an else to your if. In the else, set admitted to False.

i'v been stuck on this for days now. and its not working. please please help!

conditions.py
admitted = None

if age >= 13:
  admitted = 'true'
else:
  admitted = 'false'

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

admitted needs to be set to the built-in values True and False not strings:

admitted = None

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

thanks for your speedy response chris but the only way task 1 will work is if i put true into a string. it comes up with 'true' not defined otherwise.

ooooooh wait i have got it!! capital letters in 'True' and 'false'

Chris, Why do we delete/comment out the age = part of the first part of the challenge here? How does the if/else know what to test against without it?

Chris Freeman
Chris Freeman
Treehouse Moderator 68,441 Points

Abbymann, the challenge checker sets up a context for the code to run in. This lets it try many values for age to test each branch of flow through the code.

thankyou for your help Chris