Search⌘ K
AI Features

Challenge: Break the Loop

Explore how to create a Python loop that repeatedly asks for word inputs, skips any blank responses, and stops the loop when you enter the word bye. This lesson helps you understand loop control, input handling, and decision-making to automate tasks efficiently.

We'll cover the following...

Sometimes you want a program to keep running until the user decides to stop.

Python can do this using a while loop that runs forever, and then stopping it manually using special keywords.

Two important tools you’ll use here are:

  • break → stops the loop completely

  • continue → skips the rest of the loop and starts again

Your task:

  1. Create a loop that keeps asking the user to type a word

  2. If the user types "bye", stop the loop

  3. If the user presses Enter without typing anything, skip that input

  4. Otherwise, print what the user typed

💡 Things to keep in mind:

  • A while loop can run forever unless you stop it

  • break ends the loop

  • continue skips to the next loop cycle

  • You only need one loop

When you click Run, your program should keep responding until the user types "bye".

# Write your code here.
Asking for words, skipping blanks, and stopping at “bye”