Single instance increments shared total
Input
c = SharedCounter(); c.increment(); SharedCounter.total
Output
1
Calling increment() on the instance increases both the instance count and the shared class attribute total.
Full lesson preview
Learn how an instance method can update a class-level (shared) attribute and how to control that shared state across operations.
Problem statement
Task
Examples
Input
c = SharedCounter(); c.increment(); SharedCounter.total
Output
1
Calling increment() on the instance increases both the instance count and the shared class attribute total.
Input format
Output format
Constraints
Samples
Input
make_and_increment(2, 3)
Output
6
Two instances, each incremented 3 times -> total increments = 2 * 3 = 6.