Nested for loops and print statements

Gregory Ewing greg.ewing at canterbury.ac.nz
Tue Sep 27 18:23:46 EDT 2016


Cai Gengyang wrote:
> How are you running the interactive interpreter? Are you 
> using IDLE, or are you running Python in a command window? --- IDLE

I don't normally use IDLE on MacOSX, so I had to try it to
find out. I think I know what your problem is now.

When you type a line into IDLE ending with a colon and press
enter, it automatically indents the next line, and it does
it using *tab* characters. You can see this by selecting the
indentation with the mouse. You'll notice that it highlights
in big chunks -- those are tab characters.

This means that any extra indentation you add yourself also
needs to be done by pressing the tab key, not the space bar,
otherwise you risk mixing up tabs and spaces in ways that
Python doesn't like.

-- 
Greg



More information about the Python-list mailing list