Re: Find duplicates in a list and count them ...

2009-03-26 Thread Josh Dukes
On Thu, 26 Mar 2009 16:02:20 -0400 "D'Arcy J.M. Cain" wrote: or l = ( randint(0,9) for x in xrange(8) ) > On Thu, 26 Mar 2009 16:00:01 -0400 > Albert Hopkins wrote: > > > l = list() > > > for i in xrange(8): > > > l.append(randint(0,10)) > > ^^^ > > should

Re: Find duplicates in a list and count them ...

2009-03-26 Thread John Machin
On Mar 27, 8:14 am, paul.scipi...@aps.com wrote: > Hi D'Arcy J.M. Cain, > > Thank you.  I tried this and my list of 76,979 integers got reduced to a > dictionary of 76,963 items, each item listing the integer value from the > list, a comma, and a 1. I doubt this very much. Please show: (a) your

Re: Find duplicates in a list and count them ...

2009-03-26 Thread MRAB
Benjamin Kaplan wrote: On Thu, Mar 26, 2009 at 5:14 PM, > wrote: Hi D'Arcy J.M. Cain, Thank you. I tried this and my list of 76,979 integers got reduced to a dictionary of 76,963 items, each item listing the integer value from the list, a comma,

Re: Find duplicates in a list and count them ...

2009-03-26 Thread Benjamin Kaplan
On Thu, Mar 26, 2009 at 5:14 PM, wrote: > Hi D'Arcy J.M. Cain, > > Thank you. I tried this and my list of 76,979 integers got reduced to a > dictionary of 76,963 items, each item listing the integer value from the > list, a comma, and a 1. I think what this is doing is finding all integers > fr

RE: Find duplicates in a list and count them ...

2009-03-26 Thread Paul . Scipione
abase Administrator work: 602-371-7091 cell: 480-980-4721 -Original Message- From: D'Arcy J.M. Cain [mailto:da...@druid.net] Sent: Thursday, March 26, 2009 12:50 PM To: Scipione, Paul (ZP5296) Cc: python-list@python.org Subject: Re: Find duplicates in a list and count them ... On Thu, 2

Re: Find duplicates in a list and count them ...

2009-03-26 Thread Paul Rubin
"D'Arcy J.M. Cain" writes: > icount = {} > for i in list_of_ints: > icount[i] = icount.get(i, 0) + 1 from collections import defaultdict icount = defaultdict(int) for i in list_of_ints: icount[i] += 1 -- http://mail.python.org/mailman/listinfo/python-list

Re: Find duplicates in a list and count them ...

2009-03-26 Thread D'Arcy J.M. Cain
On Thu, 26 Mar 2009 16:00:01 -0400 Albert Hopkins wrote: > > l = list() > > for i in xrange(8): > > l.append(randint(0,10)) > ^^^ > should have been: > l.append(randint(0,9)) Or even: l = [randint(0,9) for x in xrange(8)] -- D'Arcy J.M. Cain

Re: Find duplicates in a list and count them ...

2009-03-26 Thread Albert Hopkins
On Thu, 2009-03-26 at 15:54 -0400, Albert Hopkins wrote: [...] > $ cat test.py > from random import randint > > l = list() > for i in xrange(8): > l.append(randint(0,10)) ^^^ should have been: l.append(randint(0,9)) > > hist = dict() > for i in l: >

Re: Find duplicates in a list and count them ...

2009-03-26 Thread Albert Hopkins
On Thu, 2009-03-26 at 12:22 -0700, paul.scipi...@aps.com wrote: > Hello, > > I'm a newbie to Python. I have a list which contains integers (about > 80,000). I want to find a quick way to get the numbers that occur in > the list more than once, and how many times that number is duplicated > in t

Re: Find duplicates in a list and count them ...

2009-03-26 Thread D'Arcy J.M. Cain
On Thu, 26 Mar 2009 12:22:27 -0700 paul.scipi...@aps.com wrote: > I'm a newbie to Python. I have a list which contains integers (about > 80,000). I want to find a quick way to get the numbers that occur in the > list more than once, and how many times that number is duplicated in the > list.

Find duplicates in a list and count them ...

2009-03-26 Thread Paul . Scipione
Hello, I'm a newbie to Python. I have a list which contains integers (about 80,000). I want to find a quick way to get the numbers that occur in the list more than once, and how many times that number is duplicated in the list. I've done this right now by looping through the list, getting a