Can we use break in a exception block? if yes what happens to the flow? if no why not? | Sololearn: Learn to code for FREE!
0

Can we use break in a exception block? if yes what happens to the flow? if no why not?

11th Jul 2017, 4:54 PM
Nilavan
2 Answers
0
break is used when loops are involved. Try and except blocks are not loops. Therefore, if you try to use this in the, python will likely spit a syntax error at you, aka, angry red text. You're asking python to break out of an non-existent loop. However, if your except blocks are inside a loop (or multiple), break can be used with exception blocks, and will exit/stop the innermost loop.
11th Jul 2017, 9:42 PM
Sapphire
0
we can't use break keyword inside exception block, if you write break in exception then it will throws a syntax error.
17th Jul 2017, 6:31 AM
Chandrappa B S
Chandrappa B S - avatar