Instance vs class attributes — and the bug AI ships every time — step 8 of 9
Write a Counter class with:
- An instance attribute
countthat starts at0. - A method
increment()that adds 1 toself.count. - A method
value()that returnsself.count.
Make sure the count is per-instance — two counters should not share state.
Expected output:
3
1
⌘↵ runs the editor.read, then continue.
Write a Counter class with:
- An instance attribute
countthat starts at0. - A method
increment()that adds 1 toself.count. - A method
value()that returnsself.count.
Make sure the count is per-instance — two counters should not share state.
Expected output:
3
1
this step needs the editor
on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.