Python: Find element in the list which has frequency = 2 -


let's have list:

input: ids = [123, 456, 123]

i need find element frequency 2.

output: 123

best way in python?

from collections import counter counter = counter(ids) [k k,v in counter.items() if v == 2] 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -