Monday, February 8, 2010

Indentation and block

Indentation and block

Unlike most other programming language such as c, java, in which using braces to define block; Python use whitespace and indentation to define block structure.

Example 1:
x = 0;
while(x < 10):
x += 1;
y = x;
print("x = ", x);
print("y = ", y);




Example 2:
x = 0;
while(x < 10):
x += 1;
y = x;
print("x = ", x);
print("y = ", y);




IDLE, the default IDE of Python, automatically indents lines for you.