ropering / Study

0 stars 0 forks source link

[Python] count_occurences #18

Open ropering opened 2 years ago

ropering commented 2 years ago
def count_occurrences(lst, val):
    return len([x for x in lst if x == val and type(x) == type(val)])

count_occurences([1, 1, 2, 1, 2, 3], 1) # 3