[Tutor] Looking for duplicates within a list
Ken G.
beachkid at insightbb.com
Fri Jun 11 16:31:58 CEST 2010
vijay wrote:
> Check out this code
> l= [1, 2, 3, 3, 4]
> d={}
> for item in l:
> d.setdefaut(item,0)
> d[item] +=1
> print d
> {1: 1, 2: 1, 3: 2, 4: 1}
>
>
> with regard's
> vijay
>
>
Thanks. Very interesting concept.
Ken
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100611/12e042f9/attachment.html>
More information about the Tutor
mailing list