#!/usr/bin/env python
# -*- coding:utf-8 -*-
# 猜数字
a=12;c=0 #c=3 只能玩3次
while c < 3: #True 永远为真
name = int(input('name :'))
if a == name :
print('ok')
break
elif a > name:
print('smaller')
else:
print('big')
c=c+1
#猜3次了,没猜对。是否重玩。非N重玩,N结束
if c ==3:
countine_confirm = input('do you want to keep guessing..?你还想玩吗 ')
if countine_confirm !='n':
c=0
else: #上面代码正常走完,则会执行。
print('超3次,退出!')
转载于:https://www.cnblogs.com/pojue/p/7788525.html