count() – return the number of existing list entries (count)

Code Explanation

LineDescription
1Declaration and initialization of the list myList with the values 1, 3, 3, 3, 5, 5 and 6
3The count() method counts the number of the specified element (3) in the list. The number 3 exists 3 times
4The count() method counts the number of the specified element (5) in the list. The number 5 exists 2 times
myList = [1, 3, 3, 3, 5, 5, 6]

print(myList.count(3))
print(myList.count(5))
Output
3
2