How to count the frequency of a list element two requirements: 1, statistics a random sequence [1,2,3,4,5,6 ...] The number of occurrences in the first three of the elements and the number of times 2, a piece of English article in the number of times before the first 10 words two methods:
1, the normal for loop, combined with the front of the Python foundation-------How to filter the contents of the data in a list dictionary collection based on criteria
2, counter method of self-brought library collections
Solution requirements One, two methods one:
Mister into a random list, get the largest element by method one
Get most elements
Focus on the second approach
1, first import
from Import Counter
2, A is the original list
3, get the first three frequency
Solution Requirement Two:
Statistics test the frequency of the occurrence of English words in this article
1, open, assign a value to F
2, Split F, by non-alphanumeric, generate a longer list
3, Statistics
Python basics------How to count the frequency of a list element