def main(indices): foo = True for i in indices: need_break = False if i > 2: foo = False need_break = True if need_break: break return foo