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: how to find no of times a elements in list python
thislist = (1, 3, 7, 8, 7, 5, 4, 6, 8, 5)
x = thislist.count(5)
print(x)
Example 3: How to see how many times somting is in a list python
vowels = ['a', 'e', 'i', 'o', 'i', 'u']
count = vowels.count('i')
Example 4: 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)
Example 5: how to count things in a list python
list.count(element)
list1 = ['red', 'green', 'blue', 'orange', 'green', 'gray', 'green']
color_count = list1.count('green')
print('The count of color: green is ', color_count)
Example 6: hiw ti count the number of a certain value in python
#using the .count() function where the occurence of an element you
#want to find is the thing in the paranthesis
lista = [1,1,2,3,4,5]
print(lista.count(1))
# will return 2