python get most occurring element in list
data = [1, 2, 2, 3]
print(max(set(data), key = data.count))
python get most occurring element in list
data = [1, 2, 2, 3]
print(max(set(data), key = data.count))
python find most occuring element
from collections import Counter
a = [1936, 2401, 2916, 4761, 9216, 9216, 9604, 9801]
c = Counter(a)
print(c.most_common(1)) # the one most common element... 2 would mean the 2 most common
[(9216, 2)] # a set containing the element, and it's count in 'a'
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us