[Tutor] Hi Dear!

Alan Gauld alan.gauld at btinternet.com
Thu Feb 4 12:22:54 EST 2016

On 04/02/16 12:49, Alexa kun wrote:
> Hi Dear!

Can I ask that in future you choose a subject line that reflects your
For this case it might be "IndentationError" say.

> but when I type
>>>> the_world_is_flat = True
>>>> if the_world_is_flat:
> ...     print("Be careful not to fall off!")

The problem is that is not what you typed.
And this is why we always ask for the full error
trace - thanks for including it.

>>>> if the_world_is_flat:
> ... print(Be careful not to fall off!)
>   File "<stdin>", line 2
>     print(Be careful not to fall off!)
>         ^
> IndentationError: expected an indented block

It says that there is an IndentationError which means that
Python is expecting to see a line starting in a different
place from where it does. In your case that means the line
after the 'if' is expected to be "indented". That is it
should have a few spaces in front of it (we usually
recommend 4 but Python doesn't care so long as there
is more than the preceding line).

The indentation is Python's way of telling which bits of
code need to be executed if the 'if' test is true. Anything
that is indented will be executed (or missed if the test
is false) as appropriate. The indentation needs to be the
same for all the indented lines.


if foo > 42:
   print (foo)
   f = 666

is ok but

if foo > 42:
    print (foo)
  f00 = 666        # not enough spaces

won't work.

> Please tell my why Python3 doesn't work?

It's working just fine, you only need to give it
some space(s)... :-)

Alan G
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:

More information about the Tutor mailing list