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

If this then that

I'm going to create a variable named age.

I need to make an if condition that sets admitted to True if age is 13 or more.

admitted = None

please help me

conditions.py
admitted = None
age = 122
if age >= 13:
      print("admitted is True!")
Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

It's pretty straight-forward. Here's the rest with the else. Take a peek!

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

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

You're doing really well and you're very close here. Always keep in mind that challenges are very picky. They don't want you to set the value of age. They're going to do that to test your code, so you need to keep age open for any value they send. Right now you're overwriting what they send with àge = 122'. Also, they want you to set the value of admitted to true, not print that it's true. Take a look at my solution:

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

that was great Jennifer, thanks........ How can i add an ELSE to that IF Function to set admitted to FALSE

Rob B
Rob B
11,677 Points

Terrence, If you read above you will see that Jennifer answered that very question in her first response to you.

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Actually, I added that bit after he asked about the else. P The problem is I managed to put the comment in the wrong place! Woops!