[Tutor] Extracting words..
alan.gauld@bt.com
alan.gauld@bt.com
Tue, 26 Mar 2002 23:26:05 -0000
> > Lst = map(lambda item: item not in Lst, Lst)
>
> Does this snippet work on your computer? I get "[0, 0, 0, 0, 0]".
Nope, its wrong on two counts.
1) I meant to use filter() not map() - map just returns the boolean
result of each test - false in this case!
2) It still doesn't work because you can't test the list being
built internally - you need to use an intermediate stage
- which kills performance - or an externally defined function
which is longer than the explicit loop of the earlier post....
I haven't tried it yet but will soon, but I do think you could do it
on one line using a list comprehension...
Sheepishly,
Alan g.