Answers for "count the number that appears the most in a list python"

3

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'
Posted by: Guest on July-07-2020
1

count number of repeats in list python

mylist.count(element)
Posted by: Guest on May-25-2020
3

count number items in list python

mylist = ["abc", "def", "ghi", "jkl", "mno", "pqr"]

print(len(mylist))

# output 6
Posted by: Guest on August-03-2020

Code answers related to "count the number that appears the most in a list python"

Python Answers by Framework

Browse Popular Code Answers by Language