+1 vote
in Programming Languages by (60.0k points)
How can I find the most common element in a given list in Python? Is there any function that I can use?

1 Answer

+2 votes
by (72.7k points)
selected by
 
Best answer

You can use the max() function to find the most common element in a given list.

Here is an example:

>>> aa = [1, 2, 3, 4, 4, 4, 5, 5]

>>> max(aa, key=aa.count)

4


...