Newbie White Space

Edward C. Jones edcjones at erols.com
Thu Mar 30 21:22:49 CEST 2000


In article <8bc1oo$qjc$1 at yeppa.connect.com.au>,

... "does Python check white space" ...

Python does not make blocks using {} like C. It uses indents
instead.
End-of-line means end-of-statement unless a "\" is at the end of
the line.
In the examples, I will use a "^" where ever I want a space.

while^1^==^1:
^^^^print^'infinite^loop'

#^Print^a^list^of^integers^and^their^squares.
for^i^in^range(10):
^^^^print^i
^^^^print^i**2

#^Print^all^combinations^of ^a^letter^followed^by^a^number.
for^letter^in^'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
^^^^for^numeral^in^'0123456789':
^^^^^^^^print^letter^+^numeral

Indenting is the big difference between Python and other
languages. It is,
surprisingly, not all that well documented. Go to
http://www.python.org/.
Read the Python Tutorial, Section 3.2. Then find the Python
Reference
Manual, and look at section 2.1.7.






More information about the Python-list mailing list