On Tuesday, January 1, 2013 11:10:48 AM UTC+8, Steven D'Aprano wrote:
On Sat, 29 Dec 2012 18:56:57 -0500, Terry Reedy wrote:
On 12/29/2012 2:48 PM, Quint Rankid wrote:
Given a list like:
w = [1, 2, 3, 1, 2, 4, 4, 5, 6, 1]
I would like to be able to do the following as a
On Sat, 29 Dec 2012 18:56:57 -0500, Terry Reedy wrote:
On 12/29/2012 2:48 PM, Quint Rankid wrote:
Given a list like:
w = [1, 2, 3, 1, 2, 4, 4, 5, 6, 1]
I would like to be able to do the following as a dict comprehension.
a = {}
for x in w:
a[x] = a.get(x,0) + 1
results in a having
Newbie question. I've googled a little and haven't found the answer.
Given a list like:
w = [1, 2, 3, 1, 2, 4, 4, 5, 6, 1]
I would like to be able to do the following as a dict comprehension.
a = {}
for x in w:
a[x] = a.get(x,0) + 1
results in a having the value:
{1: 3, 2: 2, 3: 1, 4: 2, 5:
In article
724d4fea-606a-4503-b538-87442f6bc...@ci3g2000vbb.googlegroups.com,
Quint Rankid qbr...@gmail.com wrote:
Newbie question. I've googled a little and haven't found the answer.
Given a list like:
w = [1, 2, 3, 1, 2, 4, 4, 5, 6, 1]
I would like to be able to do the following as a
On 12/29/2012 02:48 PM, Quint Rankid wrote:
Newbie question. I've googled a little and haven't found the answer.
Given a list like:
w = [1, 2, 3, 1, 2, 4, 4, 5, 6, 1]
I would like to be able to do the following as a dict comprehension.
a = {}
for x in w:
a[x] = a.get(x,0) + 1
results in a
On 12/29/2012 03:01 PM, Mitya Sirenef wrote:
On 12/29/2012 02:48 PM, Quint Rankid wrote:
Newbie question. I've googled a little and haven't found the answer.
Given a list like:
w = [1, 2, 3, 1, 2, 4, 4, 5, 6, 1]
I would like to be able to do the following as a dict comprehension.
a = {}
On Sat, Dec 29, 2012 at 3:09 PM, Mitya Sirenef msire...@lightbird.netwrote:
On 12/29/2012 03:01 PM, Mitya Sirenef wrote:
On 12/29/2012 02:48 PM, Quint Rankid wrote:
Newbie question. I've googled a little and haven't found the answer.
Given a list like:
w = [1, 2, 3, 1, 2, 4, 4, 5, 6,
Quint Rankid wrote:
Newbie question. I've googled a little and haven't found the answer.
Given a list like:
w = [1, 2, 3, 1, 2, 4, 4, 5, 6, 1]
I would like to be able to do the following as a dict comprehension.
a = {}
for x in w:
a[x] = a.get(x,0) + 1
results in a having the
On 2012-12-29 19:48, Quint Rankid wrote:
Newbie question. I've googled a little and haven't found the answer.
Given a list like:
w = [1, 2, 3, 1, 2, 4, 4, 5, 6, 1]
I would like to be able to do the following as a dict comprehension.
a = {}
for x in w:
a[x] = a.get(x,0) + 1
results in a
On 12/29/2012 03:15 PM, Joel Goldstick wrote:
On Sat, Dec 29, 2012 at 3:09 PM, Mitya Sirenef msire...@lightbird.net
mailto:msire...@lightbird.net wrote:
On 12/29/2012 03:01 PM, Mitya Sirenef wrote:
On 12/29/2012 02:48 PM, Quint Rankid wrote:
Newbie question. I've
On 12/29/2012 4:40 PM, Mitya Sirenef wrote:
On 12/29/2012 03:15 PM, Joel Goldstick wrote:
Would this help:
w = [1,2,3,1,2,4,4,5,6,1]
s = set(w)
s
set([1, 2, 3, 4, 5, 6])
{x:w.count(x) for x in s}
{1: 3, 2: 2, 3: 1, 4: 2, 5: 1, 6: 1}
Indeed, this is much
On 12/29/2012 2:48 PM, Quint Rankid wrote:
Given a list like:
w = [1, 2, 3, 1, 2, 4, 4, 5, 6, 1]
I would like to be able to do the following as a dict comprehension.
a = {}
for x in w:
a[x] = a.get(x,0) + 1
results in a having the value:
{1: 3, 2: 2, 3: 1, 4: 2, 5: 1, 6: 1}
Let me
On 12/29/12 15:40, Mitya Sirenef wrote:
w = [1,2,3,1,2,4,4,5,6,1]
s = set(w)
s
set([1, 2, 3, 4, 5, 6])
{x:w.count(x) for x in s}
{1: 3, 2: 2, 3: 1, 4: 2, 5: 1, 6: 1}
Indeed, this is much better -- I didn't think of it..
Except that you're still
On Sat, Dec 29, 2012 at 7:26 PM, Tim Chase python.l...@tim.thechases.comwrote:
On 12/29/12 15:40, Mitya Sirenef wrote:
w = [1,2,3,1,2,4,4,5,6,1]
s = set(w)
s
set([1, 2, 3, 4, 5, 6])
{x:w.count(x) for x in s}
{1: 3, 2: 2, 3: 1, 4: 2, 5: 1, 6: 1}
14 matches
Mail list logo