DEMO #2: We saw that range in a loop automatically counts up by 1.

Using += or -= in a loop increases or decreases a variable's value by a set amount each time the loop runs.

  • Click Run to see the demo. Follow instructions on the stage to learn about +=!
  • Take a close look at the code on the stage and in the code editor. Do you see where += is used?
  • Then click Submit and Next to continue.

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

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)