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 trialtest account
565 PointsIF statement
I don't understand the question. How to I set admitted to True, when it is already defined as None?
admitted = None
if age >= 13:
2 Answers
Steven Parker
231,236 PointsThey call storage objects "variables" because the value in them can (and generally will) be changed by the program. What you see on the top line is an assignment, not a definition.
And you can always assign a different value to a variable regardless of whether it was given a value already.
test account
565 PointsGosh I cannot believe it. I just wanna hit this site on the testicles right now. The question/answer/tips are SO vague. I don't think I would have been able to answer this if not for Steve Parker. I did not realize that I had to CHANGE admitted = True. I thought the 'if' statement would do the work like when working with the {}.
Johannes Scribante
19,175 PointsJohannes Scribante
19,175 PointsExactly as Steven has said. Here is an example:
a = None
# herea
equals Noneb = 2
# hereb
equals 2a = b
# herea
is now assigned the value ofb
whereb
equals 2, thereforea
equals 2 as welltest account
565 Pointstest account
565 PointsI understand what you explained no problem. But I supposed question did not include the original challenge request. I don't understand what they are asking for.
So how would you go about answering the challenge?
I'm going to create a variable named age.
I need you to make an if condition that sets admitted to True if age is 13 or more.
Steven Parker
231,236 PointsSteven Parker
231,236 PointsYou're quite right. You don't create the variable named "age", you just test it.
There's no "THEN" statement in Python. The code controlled by the "if" statement will follow it and be indented further to the right.
So with correct indentation, and leaving out the word "THEN", your answer should work.
test account
565 Pointstest account
565 PointsNo the answer still did not work. I am not understanding this challenge at all. I've look at the video several times and the notes. Not sure how I am supposed to deduct the answer from that.
Steven Parker
231,236 PointsSteven Parker
231,236 PointsSo if I just format the answer you gave in item (2) and remove the word "THEN" from it:
Is this your task 1 answer? And it doesn't pass?