Alternative to standard C "for"

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Sun Feb 6 18:50:38 EST 2005


adomas.paltanavicius at gmail.com wrote:

> 2) for i in range(A, B, STEP):
>      ...do something...

Note that the most common use of this is something like:

    t = 1, 2, 3

    for i in range(len(t)):
        print i, t[i]

This is best accomplished as:

    t = 1, 2, 3

    for i, e in enumerate(t):
        print i, e

Tim Delaney



More information about the Python-list mailing list