Home  >  Article  >  Operation and Maintenance  >  How to find the most frequent number in a list in python

How to find the most frequent number in a list in python

王林
王林forward
2023-05-13 22:28:041087browse

Find the number that appears most frequently in the list

test= [1,2,3,4,2,2,3,1,4,4,4]
print(max(set(test),key=test.count))
#-> 4

What are the commonly used libraries in python

Commonly used libraries in python: 1.requesuts; 2.scrapy; 3. pillow; 4. twisted; 5. numpy; 6. matplotlib; 7. pygama; 8. ipyhton, etc.

The above is the detailed content of How to find the most frequent number in a list in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete