Indentation in IronPython

Python is a language where white space (spaces and tabs) is syntactically significant. You must understand the basics of indentation before scripting in python.

Any statement that introduces a block of code should be written so that every line of the block has the same indent (leading spaces or tabs) and the indent should be at least one more than the indent of the introducing statement.

Note:

Python recommends the use of spaces over tabs.

Indenting Functions

Define a function that starts at 0 indentation:

def multInt(a,b):

Every line following def multInt that is expected to be a part of the function, must be indented to line up with the function.

def multInt(a,b):

return a

Indenting If Conditions

Each line that belongs to the body of this function should have an indent that is more than the indent used by the if statement.

def multInt(a,b):

    If a%2 == 0:

return (a * b) + 100

else:

return (a * b) + 1000