Learning IronPython #8: The if, while, and for Statements (and Array List Syntax)

Here's an example of the if statement:

>>> x = 5
>>> if x > 6:
... print "x > 6"
... elif x > 5:
... print "x > 5"
... else:
... print "x <= 5"
...
x <= 5

Here's an example of the while statement:

>>> x = 1
>>> while x < 5:
... print x
... x += 1
...
1
2
3
4

Here's an example of the for statement (with an example of how to create an array list):

>>> alist = ["a", "b", "c", "d", "e"]
>>> for i in alist:
... print i
...
a
b
c
d
e

-- Paul

------------------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.