Python | Find most frequent element in a list Last Updated : 11 Jul, 2025 Comments Improve Suggest changes 21 Likes Like Report Given a list, find the most frequent element in it. If multiple elements appear a maximum number of times, print any one of them using Python.ExampleMake a set of the list so that the duplicate elements are deleted. Then find the highest count of occurrences of each element in the set and thus, we find the maximum out of it. Python def most_frequent(List): return max(set(List), key=List.count) List = [2, 1, 2, 2, 1, 3] print(most_frequent(List)) Output2Table of ContentNaive Approach to Find Frequent Elements in a ListGet Frequent Elements in a List using CounterGet Frequent Elements in a List with Statistics LibraryFind Frequent Elements in a List using Python dictionaryNaive Approach to Find Frequent Elements in a ListThis is a brute force approach in which we make use of for loop to count the frequency of each element. If the current frequency is greater than the previous frequency, update the counter and store the element. Python def most_frequent(List): counter = 0 num = List[0] for i in List: curr_frequency = List.count(i) if(curr_frequency> counter): counter = curr_frequency num = i return num List = [2, 1, 2, 2, 1, 3] print(most_frequent(List)) Output2Get Frequent Elements in a List using CounterMake use of Python Counter which returns count of each element in the list. Thus, we simply find the most common element by using most_common() method. Python from collections import Counter def most_frequent(List): occurence_count = Counter(List) return occurence_count.most_common(1)[0][0] List = [2, 1, 2, 2, 1, 3] print(most_frequent(List)) Output2Get Frequent Elements in a List with Statistics LibraryFinding most frequent element means finding mode of the list. Hence, we use mode method from statistics. Python import statistics from statistics import mode def most_common(List): return(mode(List)) List = [2, 1, 2, 2, 1, 3] print(most_common(List)) Output2Find Frequent Elements in a List using Python dictionaryUse Python dictionary to save element as a key and its frequency as the value, and thus find the most frequent element. Python def most_frequent(List): dict = {} count, itm = 0, '' for item in reversed(List): dict[item] = dict.get(item, 0) + 1 if dict[item] >= count : count, itm = dict[item], item return(itm) List = [2, 1, 2, 2, 1, 3] print(most_frequent(List)) Output2 Create Quiz Python program to find most frequent element in a list Comment S Smitha Dinesh Semwal Follow 21 Improve S Smitha Dinesh Semwal Follow 21 Improve Article Tags : Python Python Programs python-list Python list-programs Explore Python FundamentalsPython Introduction 2 min read Input and Output in Python 4 min read Python Variables 4 min read Python Operators 4 min read Python Keywords 2 min read Python Data Types 8 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 5 min read Python Functions 5 min read Recursion in Python 4 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 4 min read Python Tuples 4 min read Python Dictionary 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 5 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 3 min read Python MySQL 9 min read Python Packages 10 min read Python Modules 3 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 3 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 4 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 3 min read StatsModel Library - Tutorial 3 min read Learning Model Building in Scikit-learn 6 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 6 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 7 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 5 min read Build a REST API using Flask - Python 3 min read Building a Simple API with Django REST Framework 3 min read Python PracticePython Quiz 1 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like