Passed along to postmas...@python.org, who generally takes care of this
sort of thing.
Skip
On Apr 1, 2017 11:19 AM, "Steve D'Aprano"
wrote:
> Can one of the mailing list moderators please remove this person's post for
> including a link to an anti-Semitic video by David Duke?
>
>
>
> On Sat, 1
Can one of the mailing list moderators please remove this person's post for
including a link to an anti-Semitic video by David Duke?
On Sat, 1 Apr 2017 07:13 pm, Robert L. wrote:
Goyim were born [...]
web.archive.org/web/20101020044210/http://www.jpost.com/JewishWorld[...]
archive.org/download/
On 3/7/2017, Sayth Renshaw wrote:
> I have got this dictionary comprehension and it
> works but how can I do it better?
>
> from collections import Counter
>
> def find_it(seq):
> counts = dict(Counter(seq))
> a = [(k, v) for k,v in counts.items() if v % 3 == 0]
> return a[0][0]
>
Sayth Renshaw writes:
>> To find an unpaired number in linear time with minimal space, try
>> stepping through the list and either adding to a set or removing from
>> it. At the end, your set should contain exactly one element. I'll let
>> you write the actual code :)
>>
>> ChrisA
>
> ChrisA the
Sayth Renshaw writes:
> Peter I really like this
>
> The complete code:
>
from collections import Counter
def find_it(seq):
> ... [result] = [k for k, v in Counter(seq).items() if v % 3 == 0]
> ... return result
You confirmed to Chris that you want the item that occurs an o
Sayth Renshaw wrote:
> Peter I really like this
>
> The complete code:
>
from collections import Counter
def find_it(seq):
> ... [result] = [k for k, v in Counter(seq).items() if v % 3 == 0]
> ... return result
> ...
test_seq = [20,1,-1,2,-2,3,3,5,5,1,2,4,20,4,-1,-2,5]
>>>
Peter I really like this
The complete code:
>>> from collections import Counter
>>> def find_it(seq):
... [result] = [k for k, v in Counter(seq).items() if v % 3 == 0]
... return result
...
>>> test_seq = [20,1,-1,2,-2,3,3,5,5,1,2,4,20,4,-1,-2,5]
>>> find_it(test_seq)
But what ma
Sayth Renshaw wrote:
> Hi
>
> I have got this dictionary comprehension and it works but how can I do it
> better?
List comprehensions (that's what you have) are nice, but overused.
> from collections import Counter
>
> def find_it(seq):
> counts = dict(Counter(seq))
There is no need to
> > But the given problem states there will always only be one number appearing
> > an odd number of times given that is there a neater way to get the answer?
>
> Take a step back for a moment. Are you trying to find something that
> appears an odd number of times, or a number of times that coun
On Wed, Mar 8, 2017 at 1:55 PM, MRAB wrote:
> Using Counter seems like a simpler way to me. I wouldn't bother about other
> ways unless that way wasn't "good enough" for some reason.
Maybe. But without being sure what the goal is, it's hard to say.
ChrisA
--
https://mail.python.org/mailman/list
On 2017-03-08 02:37, Chris Angelico wrote:
On Wed, Mar 8, 2017 at 1:28 PM, Sayth Renshaw wrote:
I have got this dictionary comprehension and it works but how can I do it
better?
from collections import Counter
def find_it(seq):
counts = dict(Counter(seq))
a = [(k, v) for k,v in cou
On Wed, Mar 8, 2017 at 1:28 PM, Sayth Renshaw wrote:
> I have got this dictionary comprehension and it works but how can I do it
> better?
>
> from collections import Counter
>
> def find_it(seq):
> counts = dict(Counter(seq))
> a = [(k, v) for k,v in counts.items() if v % 3 == 0]
>
Hi
I have got this dictionary comprehension and it works but how can I do it
better?
from collections import Counter
def find_it(seq):
counts = dict(Counter(seq))
a = [(k, v) for k,v in counts.items() if v % 3 == 0]
return a[0][0]
test_seq = [20,1,-1,2,-2,3,3,5,5,1,2,4,20,4,-1,-
13 matches
Mail list logo