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

Greg Ryan
Greg Ryan
1,777 Points

Python basics: how do set a condition to print "true" if an age of 13 or greater is input.

I have to set a condition in Python that prints true if someone inputs an age that is greater than 13. I thought that I would have to set an if condition that read:

if admitted > 13: Print("True")

this doesn't seem to be working. I think it has something to do with the condition; admitted = none, at the top of the code. Do I have to give an instruction that sets None to a number? I have been through the video and teachers notes but I can't work out what I am doing wrong.

Thanks,

 Greg.
conditions.py
admitted = None
 if admitted > 13:
        print("true")

3 Answers

Florian Tönjes
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Florian Tönjes
Full Stack JavaScript Techdegree Graduate 50,856 Points

Hey Greg,

you are checking if the variable 'admitted' is greater than thirteen. You have to check if 'age' is greater than thirteen. Also, the challenge doesn't want you to print out "true". It wants you to set the variable 'admitted' to 'True'.

Kind Regards, Florian

Greg Ryan
Greg Ryan
1,777 Points

HI Florian, Thank you for your advice. I will have to look back further into the course to get what I am trying to do straight in my head. I'm not sure how to change the variable admitted to true. Do I need to create a variable for age first then if this is greater then change admitted to true?

Greg Ryan
Greg Ryan
1,777 Points

Hi Florian,

I managed to work it out. Thank you so much for your help. This will be the first of many silly questions I am sure!!

Greg.

Florian Tönjes
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Florian Tönjes
Full Stack JavaScript Techdegree Graduate 50,856 Points

The challenge does create the 'age' variable for you and also puts a value into it.

So you can just check ' if age > 13: ' in your challenge code.

Greg Ryan
Greg Ryan
1,777 Points

Hi Florian,

I have tried this a few times but keep getting an error message that reads; "unexpected EOF while parsing ([string 1] line 1)".

I'm really not sure what I am doing wrong!