Mega Code Archive

 
Categories / Python Tutorial / Statement
 

Use break to stop execution and break out of the current loop

# Use  continue to stop execution of the current iteration and start the next iteration of the current loop word = "this is a test" string = "" for ch in word:     if ch == 'i':         string +='y'         continue     if ch == ' ':         break     string += ch print string