Python Python Basics (2015) Logic in Python Conditional Value

Amitesh Kumar
Amitesh Kumar
552 Points

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

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.

conditions.py
admitted = None
age = 13
if (age >= 13) :
    admitted = True

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 142,499 Points

Hi Amitesh,

You're on the right track. There are just a few small things:

  1. The instructions stated that it is going to "create a variable named age", so you shouldn't. You will need to delete that line of code.
  2. In python, parentheses are not required for an if statement, so remove those.
  3. There is a space before the colon (:) that is beginning the if block and that is causing a syntax error.
admitted = None

if age >= 13:
    admitted = True

Remember, that instructions for challenges are very specific and always need to be followed exactly or the challenge will fail.

Keep Coding! :) :dizzy:

Moderator note: I did delete the "answer" you added with unformatted code. The code block was included when you posted the question. If you do need to, in the future, add some more code, please use the Markdown Cheetsheet (link above the post button) to properly format code for the Community. You can also take the Markdown Basics Course. Markdown is very useful. Without it, may things (especially here in the Community) become unreadable.