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 If This Then That

error w/ if not comparison

on the 3rd line of code I'm not getting the three >>> and I think that is messing up the code. It looks to me like I'm following along, but obviously Keneth is doing something I'm missing cause he has the three >>>

>>> age = 22
>>> if age > 20:
... if not age > 25:
  File "<stdin>", line 2
    if not age > 25:
     ^
IndentationError: expected an indented block
>>>

3 Answers

Chris Adamson
Chris Adamson
132,143 Points

It's not clear how Ken got the additional prompt (>>>) but Python requires that 2nd if statement to be indented:

age = 22
if age > 20:
  if not age > 25:
Steven Parker
Steven Parker
231,248 Points

In the video, the line that shows if age > 20000: is left over from the previous demonstration, and not freshly entered. He erased the rest of the previous demonstration leaving only the >>> prompt.

A freshly entered if statement will cause the prompt to change to ... as a reminder that the next line should probably be indented.

Thank you for the info that ... means to indent. It is bizarre though, I watched closely again and Kenneth does update that 20000 to 25000 but never indents that 2nd if.

Jose Then
Jose Then
2,747 Points

I know this is older information from previous posts but I had to watch this again as well. As Steven Parker started he does erase some of the information as he goes and if you do not do the same like him in the Treehouse workspace you will get the same errors you are possibly getting now.

I started the workspace completely over and I was now able to get the exact information you were supposed to by following EXACTLY how he does it and where he erases lines at. It will then work for you.