← Back to Classes
Question 483
Count Every Instance
Count Every Instance
A class attribute belongs to the class itself, not to any one object, so Counter.count is shared by every Counter ever made. Write the body of __init__ so each new object adds one to Counter.count. Do NOT write a main block or any top-level test code; the tests construct the class. Input: one line, a whole number, which the tests read and use to construct that many objects before printing the shared count.
Expected Output:
3= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
Classes
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.