python - get max duplicate item in list -


i have list:

mylist = [20, 30, 25, 20, 30] 

after getting duplicated values indexes using

[i i, x in enumerate(mylist) if mylist.count(x) > 1] 

the result is:

`[0, 1, 3, 4]`  

having 2 pairs of duplicated values. i'd know, how can higher duplicated value? in list 30 or of it's indexes, 1 or 4, instead of whole list of duplicated values.

regards...

this 1 o(n)

>>> collections import counter >>> mylist = [20, 30, 25, 20, 30] >>> max(k k,v in counter(mylist).items() if v>1) 30 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -