Python Lists – Find most popular item in list

In this post we will be creating a Python script to find the most popular item within a list, this will be the item that has the most occurrences. For this we will using Python’s inbuilt ‘set()’ function.

See below our list for this example.

List=[1, 2, 3, 4, 4, 5, 5, 5, 5, 6]

See the snippet of code below where we find the most popular item using the ‘set()’ function.

CommonVal = max(set(List), key=List.count)

This would output the following result.


Leave a Reply