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

I cant get admitted to be true with an if condition... Ive done it two or three different ways.. feeling stupid now!

admitted = None I'm told to create an if condition that sets admitted to true if age is 13 or more. I'm told that he will make the variable called age.

2 Answers

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

I'd prefer to see what you've tried that's failed so that I can say specifically what you're doing incorrectly. Here's the code that you need:

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

First, admitted is set to None. Then we check to see if age is greater than or equal to thirteen. If it is, then we take admitted and write over the None value with True. Hope this helps!

The only thing I see different is I did not capitalize the t in true and it kept on saying true is not defined... Thank you so much. I need to pay more attention I asume.

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

The reason you were getting that true is undefined is because it is. True is a python keyword. "true" is not. If you use the one with the lower case "t" ie "true" it thinks you're referring to a variable with that name... which you haven't defined or used yet. Hope that makes sense!

Because he is making the age variable, we will not have to put that in our code. We will just make an if statement that uses the age variable. In the code below, we making an if statement that asks if age is greater than 13 (don't forget the colon). And if the age is greater than 13, then we just set the admitted variable to True. Make sure True is not in quotes (it wants the boolean value instead of a string) and make sure the T is capitalized. I didn't know what you were doing wrong since there is no code so I tried to explain everything even though you probably had most of it. Here is the code:

admitted = None

if age >= 13:
  admitted = True

I did have the code the same way several times but I did not capitalize the t in true is the only difference I seen... Then desperately started to try and make it work. And just went low iq with it.. Thanks so much