insertion sorts...

python_newbie serbulentu at gmail.com
Wed Jun 25 05:13:17 EDT 2008


On 24 Haziran, 04:33, Terry Reedy <tjre... at udel.edu> wrote:
> 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.

Thanks for all answers. At the end i ve only one point. If a decide to
copy list to iterate when will i have to do this ? Before the
iteration ? And then iterate through one list and change value of the
other ?



More information about the Python-list mailing list