I'm new to python and I'm using the book called "Automate the Boring Stuff with Python".
I was entering the following code (which was the same as the book):
while True:
print('Please type your name.')
name = input()
if name == 'your name':
break
print('Thank you!')
And I got a 'break outside loop' error. I found out that a break could only be used within loops.
Then I tried entering the following:
while True:
print('Please type your name.')
name = input()
while name == 'your name':
break
print('Thank you!')
But it didn't work, it kept asking for a name.
What do you think there was a mistake in the book or something?
question from:
https://stackoverflow.com/questions/65940602/break-outside-loop 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…