LOOPS, PART 2: For a while loop to work, we need to make sure that its condition will eventually be False.

while loops are perfect for repeating an unknown number of times. They repeat until their condition is False!

  • Determine the x-position of the net. Change the while loop condition to less than that x-position instead of 5.
  • Inside the loop, change ball_x·+=·1 to equal Get x so that it looks like this: ball_x = ball.get_x()
  • This stores the ball's new x-position each time the loop repeats. Run the program again. Do you ever miss?

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)