WARNING: This program has a bug, which means we need to fix it!

RULE: If a variable was created outside an event or function, we need to make it a global variable before changing its value inside an event or function. Check the toolkit to find Global Variable.

  • Click Run and read the error message.
  • Debug this program by making score a global variable in the click event.

To navigate the page using the TAB key, first press ESC to exit the code editor.

stage.set_background_color("black") score = 0 colors = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"] score_text = codesters.Text("Score: " + str(score), 0, 175, "red") title_text = codesters.Text("Speed Click Challenge!", 0, 200, "yellow") circle = codesters.Circle(0, 0, 100, "yellow") circle.say("Click me as much as possible in 5 seconds!", 3) def click(sprite): score += 1 score_text.set_text("Score: " + str(score)) circle.event_click(click) stage.wait(5) circle.say("Time's up!")
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)