count = 0
answer = 10
while True:
print(count)
count += 1
guess = int(input(‘猜一个‘))
if guess == answer:
print(‘ok‘)
break
elif guess > answer:
print(‘猜大了‘)
else:
print(‘猜小了‘)
if count ==10:
break
print(‘第二个while‘)
count = 0
while count <3:
count +=1
guess = int(input(‘猜一个‘))
if guess == answer:
print(‘ok‘)
break
elif guess < answer:
print(‘猜小了‘)
else:
print(‘猜大了‘)
else:
print(‘机会用完了‘)
原文:http://www.cnblogs.com/jackadam/p/7842700.html