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 trialPanos Kokoropoulos
966 PointsPython basic logic question
I am able to set up the if statement regarding age > 13 making a variable true. Next part of question says to make else statement which makes same variable false. It would seem to be a very simple else statement, but I keep getting the answer wrong. Code looks like: age = 15 if age > 13: admitted = True (this part works apparently)
I try to add:
else: admitted = False
I get the response that admitted isn't False. That doesn't seem to be a requirement of the requested code.
admitted = None
age = 15
if age > 13:
admitted = True
6 Answers
Nathan Tallack
22,160 PointsI got caught out with this one too. :P
They don't want you to declare age. In the instructions they say "I'm going to create a variable named age.".
Take out your age declaration and all will be well. :)
Keep up the great work!!!
Abdirahman Nur
750 PointsHi dears,
I've caught in the same situation too, but still unable to get it right. My code line is as follows: admitted = None if age > 13: admitted = True else: admitted = False
please advise where I got it wrong.
Panos Kokoropoulos
966 PointsAfter initial line about "admitted", need to have a line naming the variable "age". The line should look like:
age
Abdirahman Nur
750 Pointswoow!! finally it worked out!!
many thanks dear Panos :)
Abdirahman Nur
750 Pointswoow!! finally it worked out!!
many thanks dear Panos :)
Jarvis Logan
758 PointsI have the same issue. I cant seem to get it to work. admitted = None age if age > 13: admitted = "true" else: admitted = 'false' I still get 'admitted' is not false error.
Abdirahman Nur
750 PointsHi Jarvis,
first of all, make sure you have kept the spacing in every new line as it should be such as having no space before if & else and 4 time spacing before the admitted variable. One more thing your True & False should be capital and without quotes, see the code below as it should be. ''' admitted = None age if age > 13: admitted = True else: admitted = False
'''
William Gamble
979 PointsSeriously I have no idea what is missing here I keep Getting Invalid Syntax (<string>,line 5>)
admitted = None if age > 13: admitted = True else: admitted = False
Panos Kokoropoulos
966 PointsPanos Kokoropoulos
966 PointsThanks.