"""
To add the integers from 1 to 10:
"""
total=0
for i in range(11):
total += i
print total
""" The range function generates a list of 11 numbers
starting with 0, so the numbers from 0 to 10.
The for loop goes through assigning each element of
the list to the variable i.
"""
## To print a list of names, one per line:
names=['sanjoy', 'jan', 'ian']
for person in names:
print person
""" Or you can more simply do
>>> print names
which prints the list of names on one line.
"""
|