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

workspace IndentationError and SyntaxError

I'm working in the workspace on the if and if not commands. When I get to the end of this line( if age > 20000:) and press return it gives me the "..." to the left of the my next line instead of the greater than symbols (<<<) that it shows when Kenneth does it in the videos. When I get to the end of that line (if not age > 25000:) and press return, it won't let me let me start a new line and immediately this error pops up. Here's the whole thing:

age = 22000
if age > 20000:
... if not age > 25000:
File "<stdin>", line 2
if not age > 25000:
^
IndentationError: expected an indented block

After that I tried it again and put the 4 spaces before I started typing the if not command to see if that would help but I got the SyntaxError: invalid syntax error instead. I feel like there is probably something pretty simple that I'm overlooking. Here's the whole second one I tried:

age = 22000
if age > 20000:
... if age not > 25000:
File "<stdin>", line 2
if age not > 25000:
^
SyntaxError: invalid syntax

Anyway, any help would be awesome!

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi William! Yes, I was able to duplicate the "IndentationError: expected an indented block". When it goes down to the next line that starts with "..." you need to press the tab key to indent inwards then start typing the next line. When I do so, I no longer get the indentation error. This may be because of how Python regards tabs and spaces indentation. Inside one file, you may not have both tabs and space indentation. My guess is that the repl here doesn't allow for space indentation and only tab indentation. Try with the tab indentation after the "..." and see if it works!

Hope this helps! :sparkles:

Hey Thanks Jennifer! I'll give that a shot. Just out of curiosity do you think that this may have changed a little bit because I'm using python 3.5 and Kenneth was using an earlier version?

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

No. You've said that you are using workspaces. And I just fired this up in my workspaces and that was the result for me. We should all be using the same version of Python inside of workspaces. Now, if you're doing this locally there might be a difference, but even then I sort of doubt it.

Johan Elam
Johan Elam
758 Points

Had the same problem myself. First real problem in this course for me, but it is so relieving to solve it! =)