What is wrong with this code?
user = input("Enter a exit word ")
while True:
if user == "stop":
print("You've successfully left the loop.")
break
else:
user = input("Enter a exit word")
When running in Python 3.6 IDLE, the loop runs infinitely despite the exit word "stop". Can you explain what exactly is happening inside the loop? Why doesn't the break work?
Aucun commentaire:
Enregistrer un commentaire