# 30 people in the same boat, overload, need 15 people get out,
# so people lining up, and the position of the line to their number,
# number off, starting from 1, the number to 9 people get out,
# so circulates, until the ship only 15 people, ask what are the number of people getting off?
Life_num=(a + 1 for a in range (30)] # generated number sequence
# print (life_num)
J=1
While True:
If len (life_num) & lt;=15:
Print (life_num)
Break
The else:
For n in the range (len (life_num)) :
If j==9:
Print (' % a ship! '% life_num [n])
Life_num. Remove (life_num [n])
J=2
The else:
J +=1
CodePudding user response:
life_num=(a + 1 for a in range (30)] # generated number sequence
# print (life_num)
J=1
While True:
If len (life_num) & lt;=15:
Print (life_num)
Break
The else:
For n in the range (len (life_num)) :
If j==9:
Try:
If len (life_num) & lt;=15:
Break
Print (' % a ship! '% life_num [n])
Life_num. Remove (life_num [n])
J=2
Except the Exception as e:
Pass
The else:
J +=1