##左边每个=表示一个空格
print('=============111==========')
count = 1
temp = input("猜猜:")
guess = int(temp)
while guess !=8 and count <3 :
====temp = input("错了错了:")
====guess = int(temp)
====if guess == 8:
========print('对')
========break
====else:
========if guess > 8:
============print ("大了")
========else:
============print("小了")
##注意count +=1是怎样缩进的
========count +=1
print("不玩了")
代码判断不对,在大于8的判断的地方没有ciunt=+1
嵌套可以实现这样的做法
lists=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
def rl(lists, n):
for i in lists:
if i%(1+n)==0:
lists.remove(i)
print(n, lists)
if n > 1:
rl(lists[:], n-1)
rl(lists, 3)
可是为什么不简化一下
lists=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
lists1=lists[:]
for n in range(3):
for i in lists1:
if i%(2+n)==0:
lists1.remove(i)
print(lists1)