Nested for loops and print statements
Larry Hudson
orgnut at yahoo.com
Tue Sep 27 22:48:50 EDT 2016
On 09/26/2016 01:57 PM, Cai Gengyang wrote:
> Ok it works now:
>
>>>> for row in range(10):
> for column in range(10):
> print("*",end="")
>
>
> ****************************************************************************************************
>
> but how is it different from ---
>
>>>> for row in range(10):
> for column in range(10):
> print("*",end="")
>
> SyntaxError: inconsistent use of tabs and spaces in indentation
>
> Why does the example on top work and the example below doesn't work ? The only difference is that the "print" statement is one space different from each other. Forgive me if i can't explain things clearly over the forum
>
As they came through in the newsgroup, BOTH run correctly, because both versions had leading
spaces only. (I did a careful copy/paste to check this.) Tabs are sometimes handled
incorrectly/inconsistently in newsgroup postings. But if you read the Traceback error message,
it is telling you that you have a mix of tabs and spaces _in your original_. READ the error
messages, they are important!
--
-=- Larry -=-
More information about the Python-list
mailing list