约瑟夫环(函数调用版) 使用函数调用,每次更改游戏规则只需在函数定义内更改即可 def ysf(x,y,z): #定义函数 list1 = [i for i in range(1,x)] #自行更改范围 k = 0 while len(list1)>z: i = 0 while i<len(list1): k += 1 if k == y: list1.remove(list1[i]) k =0 else: i +=1 print(list1) return list1 ysf(40,3,2) #调用函数