STEP 7: Let's try changing the condition of our loop to see what happens. This will control whether it is infinite!

The condition of a while loop must start out as True. Otherwise, the loop will not run at all!

  • Change the value of choice from "This is a string." to "hello". Click Run. What happens now?

The loop doesn't run because choice does equal "hello" so its initial condition of choice != "hello" is False.

  • Change the string in the while loop condition from "hello" to "no". Run then Stop before submitting!

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)