Basic example
Input
count_occurrences([1, 2, 1, 3, 1], 1)
Output
3
The value 1 appears three times in the list.
Full lesson preview
Count how many times a given value appears in a list.
Problem statement
Task
Examples
Input
count_occurrences([1, 2, 1, 3, 1], 1)
Output
3
The value 1 appears three times in the list.
Input format
Output format
Constraints
Samples
Input
count_occurrences(['a', 'b', 'a'], 'a')
Output
2
The string 'a' appears twice.