[Python-ideas] More classical for-loop

Chris Angelico rosuav at gmail.com
Thu Feb 16 22:59:03 EST 2017


On Fri, Feb 17, 2017 at 2:13 PM, Mikhail V <mikhailwas at gmail.com> wrote:
> Common use case:
>
> L = [1,3,5,7]
>
> for i over len(L):
>    e = L[i]
>
> or:
>
> length = len(L)
> for i over length:
>    e = L[i]

Better use case:

for i, e in enumerate(L):

ChrisA


More information about the Python-ideas mailing list