python how to stop a for loop without break