MediumPro challengePython
Decorators — Call Counter
PythonDecoratorsFunctions
Implement solve(calls) that:
1. Defines a count_calls decorator that tracks how many times the wrapped function has been called via a call_count attribute on the wrapper.
2. Applies the decorator to a dummy function.
3. Calls that function calls times.
4. Returns call_count.
solve(3) # → 3
solve(0) # → 0
solve(10) # → 10Constraints
call_countmust start at0before the first call.- The wrapper must accept any positional and keyword arguments (
*args, **kwargs).
Sample tests
Test #1call_count is 3 after 3 calls
Input: [3]
Output: 3
Test #2call_count is 0 when called 0 times
Input: [0]
Output: 0
Test #3call_count is 1 after a single call
Input: [1]
Output: 1