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

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 145,860 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.