$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · easy · #86

What is the correct fix?

count = 0
def bump():
    count += 1
bump()
  1. Declare global count inside the function
  2. Declare nonlocal count inside the function
  3. Change count += 1 to count = count + 1
  4. Move the count = 0 line into bump
Assigning makes count local; global binds it to the module-level name.
Play Problem Solving ▸