Extracting from a list

Cliff Wells logiplexsoftware at earthlink.net
Wed Apr 10 17:54:30 EDT 2002


On Wed, 10 Apr 2002 23:42:46 +0200
Daniel Dittmar wrote:

> How about:
> 
> for i in xrange (len (lst) - 1, -1, -1):
>      item = lst [i]
>      if item < 5:
>          print item
>          del lst [i]
> 
> This makes it possible to delete items from the list as the access is 
> back to front.

Good answer.  Why didn't I think of that...

-- 
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308  (800) 735-0555 x308





More information about the Python-list mailing list