Lesson 14 of 34
break and continue
8 min 30 XP
break stops the whole loop immediately. continue skips the rest of this round and moves to the next one.
Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.while True means “keep going forever” until a break. It's handy for reading input until the user types “stop”.
Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.