people = {} for a in range(1,31): people[a] = a i = 1 j = 0 k = 0 while i <=31: if i == 31: i = 1 continue elif k ==15: break else: if people[i] == 0: i += 1 continue else: j += 1 if j == 9: people[i] = 0 print("{}下船了".format(i)) k += 1 j = 0 else: i += 1 continue