def homework():
while True:
i = 3
for i in range(3, 0, -1):
inp_num = input("请输入>>").strip()
if inp_num.isdigit():
inp_num = int(inp_num)
if inp_num == 18:
return print('Yes')
else:
if str(i) in ('2', '3'):
print('你还有' + str(i-1) + '次机会,wrong number!Please try again')
else:
print("请输入数字")
i = i + 1
times(i)
def times(i):
if i == 1:
while True:
inp_choose = input("While youw try for another 3times? \n 'y' for continue or 'n' quit>>")
if inp_choose in ('n', 'no', 'N', 'y', 'Y', 'yes', 'YES'):
if inp_choose in ('n', 'no', 'N'):
exit()
elif inp_choose in ('y', 'Y', 'yes', 'YES'):
return i
else:
print("请输入y or n")
homework()
猜数游戏
最新推荐文章于 2024-05-05 19:55:51 发布