Friday, January 8, 2010

Two ways of looping

Here are two ways of looping...
Lets say you have a list like this:
x = ("a", "b", "c", "d")
One way to loop through the list is like this:
for item in x:
    print "item = ", item
Another way of looping is like this:
for counter in range(len(x)):
    print "item = ", x[counter]

No comments:

Post a Comment