Nested for loops and print statements

jmp jeanmichel at sequans.com
Mon Sep 26 13:15:10 EDT 2016


On 09/26/2016 06:54 PM, Cai Gengyang wrote:
> 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 ?

Please do not top-post in this list. Put your text after the message you 
quote.


Tabs and spaces are 2 different characters, tab ASCII code is 9, space 
ASCII code is 32.

You *need* to understand that they are 2 differents characters.

The problem come with their representation.

1/ a space is represented by 1 whitespace
2/ a tab is represented by x whitespaces. The number x depends on your 
text editor.

When you want to indent a python block, you put whitespaces on its left 
to indent it. You can indent using either tabs or spaces.

Python does not tell you which one to use, but it tells you to choose 
*one* method, and stick with it.

jm





More information about the Python-list mailing list