pythonbook/Python 基础教程/1.5.7 C练习3.py

14 lines
369 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 3.有n个人围成一圈顺序排号。从第一个人开始报数从1到3报数
# 凡报到3的人退出圈子问最后留下的是原来第几号的那位。
list = [i for i in range(1,200)]
print(list)
while True:
list.pop(2)
before = list[:2]
list = list[2:]
list.extend(before)
if list.__len__()<=2:
break
print(list)