第二章 设计一个的报数小游戏。
28人的小游戏 ,从1到28 号报数重复1-3,报到3的人坐下,到最后剩下俩人的序号。
list=([i for i in range(1,29)])
list
[1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28]
将前两个数字设为变量a,b
用list.pop()
将第一个数字移除并返回变量a
同上 ———— -将第二个数字移除并返回变量b
再移除第三位数字
最后将a ,b 添加到序位之后
list.append(a)
list.append(b)
```python
while len(list)>2:
a = list.pop(0)
b = list.pop(0)
list.pop(0)
list.append(a)
list.append(b)
list
现在做一个循环
只要list >2 就继续循环遍历。
while len(list)>2:
[13, 23]