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

王林
Release: 2023-05-13 22:28:04
forward
1082 people have browsed it

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
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!