Intermediate
A counter that remembers
Write make_counter(start=0) that returns a function. Each call to that function adds 1 to a remembered count and returns the new count.
Two counters must be independent. The first call of a counter made with start=0 returns 1, and the first call of one made with start=10 returns 11.
What Check tests
- Counts 1, 2, 3
- Counters are independent
- Honours start
- Counters with different starts do not interfere
- A negative start works
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.