Confused over Lists
Eric Brunel
eric.brunel at pragmadev.com
Fri Aug 2 10:38:15 EDT 2002
Thys Meintjes wrote:
> Hi Paul,
>
> Usually a bad idea to iterate & manupilate the same list,
> rather do something like this:
>
> demoList = [1, 1, 2, 3, 4, 5]
> for num in demoList[:]:
> ...
And for your specific problem, you may just do:
demoList = [x for x in demoList if x != 1]
You may also use the "filter" built-in function, but I'll let you play with
this one if you need it.
HTH
--
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com
More information about the Python-list
mailing list