375 B
375 B
title, tags, firstSeen, lastUpdated
| title | tags | firstSeen | lastUpdated |
|---|---|---|---|
| count_occurrences | list,beginner | 2021-01-10T00:00:36+02:00 | 2021-01-10T00:00:36+02:00 |
Counts the occurrences of a value in a list.
- Use
list.count()to count the number of occurrences ofvalinlst.
def count_occurrences(lst, val):
return lst.count(val)
count_occurrences([1, 1, 2, 1, 2, 3], 1) # 3