<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<a class="moz-txt-link-abbreviated" href="mailto:davidheiserca@gmail.com">davidheiserca@gmail.com</a> wrote:
<blockquote cite="mid:BE2274A85B224813B0D95D483A050B3A@dheiser"
type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.5945" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">How about this?</font></div>
<div> </div>
<div><font face="Arial" size="2">List = [1, 2, 3, 3, 3, 4, 5, 5]<br>
for Item in list(set(List)):<br>
print Item, List.count(Item)</font></div>
<div> </div>
<div> </div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">-----
Original Message ----- </div>
<div
style="background: rgb(228, 228, 228) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>From:</b>
<a moz-do-not-send="true" title="beachkid@insightbb.com"
href="mailto:beachkid@insightbb.com">Ken G.</a> </div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>To:</b>
<a moz-do-not-send="true" title="steve@pearwood.info"
href="mailto:steve@pearwood.info">Steven D'Aprano</a> </div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Cc:</b>
<a moz-do-not-send="true" title="tutor@python.org"
href="mailto:tutor@python.org">tutor@python.org</a> </div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Sent:</b>
Friday, June 11, 2010 9:09 AM</div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Subject:</b>
Re: [Tutor] Looking for duplicates within a list [SOLVED]</div>
<div><br>
</div>
<br>
Steven D'Aprano wrote:
<blockquote cite="mid:201006120149.55173.steve@pearwood.info"
type="cite">
<pre wrap="">On Sat, 12 Jun 2010 12:58:19 am Alan Gauld wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Have you looked at the count method of lists?
Something like:
counts = set(( item, mylist.count(item)) for item in mylist if
mylist.count(item) > 1)
</pre>
</blockquote>
<pre wrap=""><!---->
That's a Shlemiel the Painter algorithm.
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://www.joelonsoftware.com/articles/fog0000000319.html">http://www.joelonsoftware.com/articles/fog0000000319.html</a>
</pre>
<blockquote type="cite">
<pre wrap="">Seems to work...
</pre>
</blockquote>
<pre wrap=""><!---->
You say that now, but one day you will use it on a list of 100,000
items, and you'll wonder why it takes 45 minutes to finish, and curse
Python for being slow.
</pre>
</blockquote>
<pre wrap="">Hee, hee. Will investigate further. Thanks.
Ken
</pre>
<p> </p>
<hr> ___</blockquote>
</blockquote>
Oh, a nice one. Many thanks.<br>
<br>
Ken<br>
</body>
</html>