program structure and control flow the break and continue statements apply only to the innermost loop being executed if it' necessary to break out of deeply nested loop structureyou can use an exception python doesn' provide "gotostatement you can also attach the else statement to loop constructsas in the following examplefor-else for line in open("foo txt")stripped line strip(if not strippedbreak process the stripped line elseraise runtimeerror("missing section separator"the else clause of loop executes only if the loop runs to completion this either occurs immediately (if the loop wouldn' execute at allor after the last iteration on the other handif the loop is terminated early using the break statementthe else clause is skipped the primary use case for the looping else clause is in code that iterates over data but which needs to set or check some kind of flag or condition if the loop breaks prematurely for exampleif you didn' use elsethe previous code might have to be rewritten with flag variable as followsfound_separator false for line in open("foo txt")stripped line strip(if not strippedfound_separator true break process the stripped line if not found_separatorraise runtimeerror("missing section separator"exceptions exceptions indicate errors and break out of the normal control flow of program an exception is raised using the raise statement the general format of the raise statement is raise exception([value])where exception is the exception type and value is an optional value giving specific details about the exception here' an exampleraise runtimeerror("unrecoverable error"if the raise statement is used by itselfthe last exception generated is raised again (although this works only while handling previously raised exceptionto catch an exceptionuse the try and except statementsas shown heretryf open('foo'except ioerror as estatements lib fl ff