Python Language Arrays Check for number of occurrences of an element using count() method

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

count() will return the number of times and element appears in an array. In the following example we see that the value 3 occurs twice.

my_array = array('i', [1,2,3,3,5])
my_array.count(3)
# 2


Got any Python Language Question?