Challenge: Break the Loop
Explore how to use break and continue statements within while loops to control program execution. You will learn to create a loop that repeatedly accepts user input, stops when the user types 'bye', skips empty inputs, and prints valid entries. This lesson helps you understand managing loop behavior and decision-making in Python programs.
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 completelycontinue→ skips the rest of the loop and starts again
Your task:
Create a loop that keeps asking the user to type a word
If the user types
"bye", stop the loopIf the user presses Enter without typing anything, skip that input
Otherwise, print what the user typed
💡 Things to keep in mind:
A
whileloop can run forever unless you stop itbreakends the loopcontinueskips to the next loop cycleYou only need one loop
When you click Run, your program should keep responding until the user types "bye".
# Write your code here.