classes — reading what ai just wrote you8 / 9
instance vs class attributes — and the bug ai ships every time
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.
Booting Python…
Output
[promptdojo:~]$ _