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
Post a Comment