Challenge: Break the Loop
Explore how to create while loops that keep running based on user input, using break to stop loops and continue to skip iterations. Gain practical experience in controlling program flow by building a loop that interacts with user input until a specific word is entered.
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.