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 statement

I don't understand the question. How to I set admitted to True, when it is already defined as None?

conditions.py
admitted = None
if age >= 13:

2 Answers

Steven Parker
Steven Parker
231,236 Points

They 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.

Johannes Scribante
Johannes Scribante
19,175 Points

Exactly as Steven has said. Here is an example:
a = None # here a equals None
b = 2 # here b equals 2
a = b # here a is now assigned the value of b where b equals 2, therefore a equals 2 as well

I 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.

  1. The variable name age is not created yet and I think i'm not supposed to create it.
  2. We are not using the THEN statement yet. So that I may answer ====if age >=13: THEN admitted = True====

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
Steven Parker
231,236 Points

You'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.

No 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
Steven Parker
231,236 Points

So if I just format the answer you gave in item (2) and remove the word "THEN" from it:

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

Is this your task 1 answer? And it doesn't pass?

Gosh 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 {}.