Nested for loops and print statements

Jussi Piitulainen jussi.piitulainen at helsinki.fi
Mon Sep 26 04:51:57 EDT 2016


Cai Gengyang writes:

> These are my attempts ---
>
>>>> for row in range(10):
>     for column in range(10):
> 	print("*",end=" ")
> 	
> SyntaxError: inconsistent use of tabs and spaces in indentation

What do you type yourself? Could it be that your software starts the
second line with a tab automatically and then you type spaces yourself?

When I type commands to the Python interpreter, it looks like this:

    >>> if 1:
    ...    print(1)
    ... 
    1

The interpreter inserts the dots below the prompt, and a space, and here
I have inserted three more spaces for indentation. The interpreter then
ignores those dots and space, and it doesn't seem to let me use any tabs
anyway.

You are running the interpreter in a different way. That's fine. But
what exactly are you doing?

(If you are using the spacebar, try the tabulation key instead. If you
are using the tabulation key, try the spacebar instead.)



More information about the Python-list mailing list