python break out of while loop in if statement