insertion sorts...

Terry Reedy tjreedy at udel.edu
Tue Jun 24 03:33:09 CEST 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