Python ALIVE AND DEAD – JosephLoendorf
参考方法:
def check_count(count1, count2, list):
if count1 ==9:
count1 =1
if count2 == len(list):
count2 =0
else:
count2 = count2
else:
count1 +=1
if count2 == len(list)-1:
count2 =0
else:
count2 +=1
return count1, count2
num_ppl =int(input('Key in the number of people: '))
list =[]
for i in range(1, num_ppl+1):
list.append(i)
print(list)
count1 =1
count2 =0
while len(list)>15:
if count1 ==9:
print('No.'+ str(list.pop(count2))+' jump into the river!')
count1, count2 = check_count(count1, count2, list)
else:
count1, count2 = check_count(count1, count2, list)
print('Survivors:',end=' ')
print(list)