Simple python iteration question

Shawn Milochik Shawn at Milochik.com
Tue Aug 14 12:47:37 EDT 2007


<snip>
> this will get index and item at index,
>
> for i in range(0, len(l)):
>     print i
>     print l[i]
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


Enumerate is better here -- it provides the same result and that's
what it's for. However, if you do use range, the zero is unnecessary
-- beginning at zero is the default.



More information about the Python-list mailing list