newbie : removing recurring element from lists

Mark Rowe bdash at gmx.net
Fri Oct 11 06:14:40 EDT 2002


On 2002-10-11 11:03:45 +0100 Andrew Thompson 
<andrew.thompson at ashecastle.com> wrote:

> Much better to let the machine do the work :
> '
> 
> while aList.__contains__(yourValue):
> 	aList.remove(yourValue)
> 
> '

Its probably a bit cleaner to phrase that as

while yourValue in aList:
    aList.remove(yourValue)


HTH,
Mark





More information about the Python-list mailing list