Loading...
Loading...
Loading...
Write a recursive function that counts how many times a target appears in a list. Pass an index, not a slice. Read the list and the target.
Example
Input
5 3 1 3 3 2 3
Output
3
3 appears three times.
Try the problem first. Open one hint at a time.
The base case is when the index reaches the end.
Add 1 when the current item equals the target, then move to the next index.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor