Python most_common() Function Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report most_common() function is a method provided by the Counter class in Python's collections module. It returns a list of the n most common elements and their counts from a collection, sorted by frequency. Example: Python from collections import Counter a = ['apple', 'banana', 'apple', 'orange', 'banana', 'apple'] # create a Counter object counter = Counter(a) # elements according to the frequency in decreasing order res = counter.most_common() print(res) Output[('apple', 3), ('banana', 2), ('orange', 1)] Syntax of most_common()most_common(n)Parameters:n (optional): An integer specifying how many of the most common elements to retrieve. Defaults to returning all elements.Returns: A list of tuples containing the n most common elements and their counts, sorted in descending order by frequency.Examples of most_common()Example 1: Finding the Most Common Words in a String Python from collections import Counter s = "Ram and Shyam are friends. Also, Ram and Ghanshyam are college friends. All of them Studies from GeeksforGeeks" res = Counter(s.split()).most_common(3) print(res) Output[('Ram', 2), ('and', 2), ('are', 2)] Explanation: The function splits the text into words and counts how many times each word appears. The three most common words are returned along with their counts.Example 2: Counting Character Occurrences Python from collections import Counter a = "abracadabra" # Get the most common character and its count res = Counter(string).most_common(1) print(res) Output[('a', 5)] Explanation: The function counts the occurrence of each character in the string and returns the most common character ('a') along with its frequency (5 times).Example 3: Identifying Popular Items in a list Python from collections import Counter a = ['apple', 'banana', 'apple', 'orange', 'banana', 'apple'] res = Counter(items).most_common(1) print(res) Output[('apple', 3)] Explanation: The function counts how many times each item appears in the list and returns the most common item ('apple') with its frequency (3 times).Related Articles:Python collections CounterPython tutorial Create Quiz Comment O oceanofknow6flv Follow 0 Improve O oceanofknow6flv Follow 0 Improve Article Tags : Python Python-Functions Python collections-module 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