insertion sorts...
Terry Reedy
tjreedy at udel.edu
Mon Jun 23 21:33:09 EDT 2008
Matimus wrote:
> May I suggest you look into using `enumerate`:
>
>>>> for i, val in enumerate([4,5,6]):
> ... print i, val
> ...
> 0 4
> 1 5
> 2 6
>
> It allows you to get the index and the value at the same time, which
> should eliminate the need for `aList.index`.
I thought of suggesting that, but indirectly iterating over a list that
is being modified with enumerate has the same problem as directly
interating over the same changing list.
More information about the Python-list
mailing list