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

Not sure how to go about this challenge.... Every time I add a line of code for if statement get syntax error on line 1

Please help

conditions.py
admitted = None
if admitted <= 13

2 Answers

Steven Parker
Steven Parker
231,269 Points

Here's a few hints:

  • the challenge said, "I need you to make an if condition that sets admitted to True if age is 13 or more."
  • so you don't want to test admitted, you want to test age
  • you want to test for 13 or more, but "<= 13" tests for 13 or less
  • the "if" statement should end with a colon (":")
  • after the "if" line you'll need an assignment statement (this time, for admitted)

Ok got it. Ok so I tried this and now it says "age isnt = True"

admitted = None if age <= 13: age = True also tried

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

and get the same result

Steven Parker
Steven Parker
231,269 Points

That first one is close but it still uses "<= 13" which tests for 13 or less. But the instructions say to test for "13 or more". There's another operator (also a pair of symbols) which has that meaning.

Also, when posting code, always use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. :arrow_heading_down: Or watch this video on code formatting.

Ok I got it now. It was a simple syntax error stopping me on the 2nd step. It said Task 1 is no longer passing which confused me. I structured it like this

admitted = None
   if >= 13:
      admitted = True
      else:
         admitted = False

when I should have structured it like this

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

Appreciate the help Steven