<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Count the duplicates in a Python List</title>
	<atom:link href="http://bigbadcode.com/2007/04/04/count-the-duplicates-in-a-python-list/feed/" rel="self" type="application/rss+xml" />
	<link>http://bigbadcode.com/2007/04/04/count-the-duplicates-in-a-python-list/</link>
	<description>this blog is retired. I&#039;m leaving it up as a reference</description>
	<lastBuildDate>Tue, 12 Apr 2011 08:42:56 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Diego Castro</title>
		<link>http://bigbadcode.com/2007/04/04/count-the-duplicates-in-a-python-list/#comment-5574</link>
		<dc:creator>Diego Castro</dc:creator>
		<pubDate>Fri, 17 Dec 2010 20:02:51 +0000</pubDate>
		<guid isPermaLink="false">http://bigbadcode.com/2007/04/04/count-the-duplicates-in-a-python-list/#comment-5574</guid>
		<description>Thanks man, 
Just a correction ... the Set on the seco0nd line should be set (lowercase)

(at least changing the case made it work here)</description>
		<content:encoded><![CDATA[<p>Thanks man,<br />
Just a correction &#8230; the Set on the seco0nd line should be set (lowercase)</p>
<p>(at least changing the case made it work here)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan</title>
		<link>http://bigbadcode.com/2007/04/04/count-the-duplicates-in-a-python-list/#comment-5537</link>
		<dc:creator>Stefan</dc:creator>
		<pubDate>Thu, 04 Jun 2009 11:01:13 +0000</pubDate>
		<guid isPermaLink="false">http://bigbadcode.com/2007/04/04/count-the-duplicates-in-a-python-list/#comment-5537</guid>
		<description>Thanks, this was a useful snippet!</description>
		<content:encoded><![CDATA[<p>Thanks, this was a useful snippet!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sfrank</title>
		<link>http://bigbadcode.com/2007/04/04/count-the-duplicates-in-a-python-list/#comment-5485</link>
		<dc:creator>sfrank</dc:creator>
		<pubDate>Fri, 17 Oct 2008 11:16:06 +0000</pubDate>
		<guid isPermaLink="false">http://bigbadcode.com/2007/04/04/count-the-duplicates-in-a-python-list/#comment-5485</guid>
		<description>Thanks, this was what I was looking for, couldn&#039;t see how to do it!</description>
		<content:encoded><![CDATA[<p>Thanks, this was what I was looking for, couldn&#8217;t see how to do it!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Eloff</title>
		<link>http://bigbadcode.com/2007/04/04/count-the-duplicates-in-a-python-list/#comment-5476</link>
		<dc:creator>Ian Eloff</dc:creator>
		<pubDate>Sun, 21 Sep 2008 19:05:26 +0000</pubDate>
		<guid isPermaLink="false">http://bigbadcode.com/2007/04/04/count-the-duplicates-in-a-python-list/#comment-5476</guid>
		<description>Another way to do this is:

&gt;&gt;&gt; from collections import defaultdict
&gt;&gt;&gt; lst = [&#039;I1&#039;,&#039;I2&#039;,&#039;I1&#039;,&#039;I3&#039;,&#039;I4&#039;,&#039;I4&#039;,&#039;I7&#039;,&#039;I7&#039;,&#039;I7&#039;,&#039;I7&#039;,&#039;I7&#039;]
&gt;&gt;&gt; def count_dups(l):
...     tally = defaultdict(int)
...     for x in l:
...         tally[x] += 1
...     return tally.items()
...     
&gt;&gt;&gt; count_dups(lst)
[(&#039;I1&#039;, 2), (&#039;I3&#039;, 1), (&#039;I2&#039;, 1), (&#039;I4&#039;, 2), (&#039;I7&#039;, 5)]</description>
		<content:encoded><![CDATA[<p>Another way to do this is:</p>
<p>&gt;&gt;&gt; from collections import defaultdict<br />
&gt;&gt;&gt; lst = ['I1','I2','I1','I3','I4','I4','I7','I7','I7','I7','I7']<br />
&gt;&gt;&gt; def count_dups(l):<br />
&#8230;     tally = defaultdict(int)<br />
&#8230;     for x in l:<br />
&#8230;         tally[x] += 1<br />
&#8230;     return tally.items()<br />
&#8230;<br />
&gt;&gt;&gt; count_dups(lst)<br />
[('I1', 2), ('I3', 1), ('I2', 1), ('I4', 2), ('I7', 5)]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

