STEP 10: Great, now we need to stop the loop when we have valid input and tell the user when we don't.

We can use break to exit a loop when it's the right time, which in this case is at the end of the try block.

  • Go to and drag Break onto the last line of the try block.
  • If we do get an error, let's let the user know! Delete print("Cannot·divide·by·0") from the except block.
  • In GRAPHICS, go to . Drag Say into the except. Change the text to "Enter a number!"

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)