Extracting from a list

Sean 'Shaleh' Perry shalehperry at attbi.com
Wed Apr 10 18:15:45 EDT 2002


On 10-Apr-2002 Cliff Wells wrote:
> 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...
> 

because python coding does not make you think about counting loops ...





More information about the Python-list mailing list