start=0 end=5 board=[-1,0,1,2,3,4,5,6,7,8] test_set=[] for box in board: if box in range(start+1,end): test_set.append(box) print(test_set)