Nested for loops and print statements

Cai Gengyang gengyangcai at gmail.com
Mon Sep 26 12:54:39 EDT 2016


What is a tab and what is a space in python and what's the difference ?

Which piece of code is indented with tabs and which one is indented with spaces ?




On Tuesday, September 27, 2016 at 12:40:16 AM UTC+8, MRAB wrote:
> On 2016-09-26 16:25, Cai Gengyang wrote:
> > 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="")
> >
> [snip]
> 
> They are not exactly the same code. They are indented differently (tabs 
> vs spaces), and that matters in Python.




More information about the Python-list mailing list