Basic usage
Input
c = Counter(); c.increment(3); c.count
Output
3
Incrementing 3 times yields a count of 3. The property count exposes the internal counter.
Full lesson preview
Learn how to use a property deleter to reset an object's internal cached/stateful data cleanly.
Problem statement
Task
Examples
Input
c = Counter(); c.increment(3); c.count
Output
3
Incrementing 3 times yields a count of 3. The property count exposes the internal counter.
Input
c = Counter(); c.increment(5); del c.count; c.count
Output
0
Deleting the property using the deleter resets the internal counter to 0.
Input format
Output format
Constraints
Samples
Input
inc_and_get(4)
Output
4
Creates a Counter, increments 4, returns 4.