python count list item occurrences code example
Example 1: python count matching elements in a list
# Basic syntax:
sum(1 for item in your_list if item == "some_condition")
# This counts the items in your_list for which item == "some_condition"
# is true. Of course, this can be changed to any conditional statement
Example 2: python find number of occurrences in list
student_grades = [9.1, 8.8, 10.0, 7.7, 6.8, 8.0, 10.0, 8.1, 10.0, 9.9]
samebnumber = student_grades.count(10.0)
print(samebnumber)