promptdojo_

Instance vs class attributes — and the bug AI ships every time — step 8 of 9

Write a Counter class with:

  • An instance attribute count that starts at 0.
  • A method increment() that adds 1 to self.count.
  • A method value() that returns self.count.

Make sure the count is per-instance — two counters should not share state.

Expected output:

3
1

full-screen editor opens — close anytime to keep reading.