Loading Teachly…
An AI assistant wrote add_to_total(n) to add n to a running total that's meant to persist across calls, using a module-level total variable. Calling it crashes immediately.
Starting from total = 0: add_to_total(5) is 5. Calling add_to_total(3) then add_to_total(4) returns 3, then 7. add_to_total(-2) is -2 (from 0).