Nested for loops and print statements

Cai Gengyang gengyangcai at gmail.com
Mon Sep 26 11:25:15 EDT 2016


I just wanted to note that sometimes the code works, sometimes it doesn't. (even though both are exactly the same code) ... Weird , dum dum dum

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

	   
****************************************************************************************************





On Monday, September 26, 2016 at 5:36:26 PM UTC+8, Steven D'Aprano wrote:
> On Monday 26 September 2016 18:32, Cai Gengyang wrote:
> 
> > These are my attempts ---
> 
> That's nice. Do you have a question?
> 
> 
> > SyntaxError: inconsistent use of tabs and spaces in indentation
> 
> When you indent, press TAB or SPACE but not both.
> 
> This error can only happen if you are use spaces for some lines and tabs for 
> other lines. Do not do that. Use spaces only or tabs only, never both.
> 
> 
> > SyntaxError: expected an indented block
> 
> You forgot to indent at all. You must indent with at least one space or one 
> tab.
> 
> > SyntaxError: inconsistent use of tabs and spaces in indentation
> 
> Use only spaces, or only tabs, never both. If you use spaces for one line, then 
> always use spaces. If you use tabs for one line, then always use tabs.
> 
> > SyntaxError: inconsistent use of tabs and spaces in indentation
> 
> Same as above.
> 
> 
> 
> 
> 
> -- 
> Steven
> git gets easier once you get the basic idea that branches are homeomorphic 
> endofunctors mapping submanifolds of a Hilbert space.



More information about the Python-list mailing list