python for loop end condition