I have written this very simple code so far but before I started expanding it, I have noticed that the while loop runs for one more time even though it should break.
x = 2
answer = None
prompt = "> "
while True:
print(x)
x = x + 1
if answer not in ["no", "NO", "nO", "No"]:
print("Continue?")
answer = input(prompt)
else:
break
This is what I get when I run the code:
2
Continue?
> no
3
I would expect that the "3" would not show because the while loop should already be escaped from. What am I not understanding here?