STEP 10: Let's make our loop stop if the user guessed correctly. To do that we'll use a break statement.

The break command stops the loop if the program reaches that line of code.

  • First, change the test value from "yes" to rand_num.
  • Then, change the string in .say() to "Great job, you guessed my number!"
  • Go to and drag out Break. Drop it at the bottom of your program, INSIDE the if statement.

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)