python break for loop in if condition