splitting tables

John J. Lee jjl at pobox.com
Fri Feb 13 08:12:31 EST 2004


Skip Montanaro <skip at pobox.com> writes:

>     robsom> ... I (still) don't like the "for in range()" way to build
>     robsom> loops.
> 
> That's needed only when you need a numeric index.  Much of the time you can
> just iterate over a container object:
> 
>     for element in mylist:
>         print element
> 
> or
> 
>     for key in mydict:
>         print (key, mydict[key])

also (Python 2.3):

for index, element in enumerate(mylist):
    # blah, blah


John



More information about the Python-list mailing list