Python Python Basics All Together Now Branch and Loop

Steven Zhang
Steven Zhang
310 Points

repeating the code until a certain input

Before you read the question, please look at where I am in the python language course.

I want to repeat my code over and over before the user inputs a certain word. I was thinking of While loops or functions. Is there any way I can repeat the code with just while loops, and how?

1 Answer

Steven Parker
Steven Parker
194,599 Points

Repeating code is exactly what loops are good for. A simple example that meets your description might be:

word = None
while word != "certain":
    word = input("What is the special word? ")
print("Yep, that was it!")