import random
n = int(input("请输入洞口的个数:"))
m = int(input("请输入玩家游戏次数:"))
t = 1
tuzi = int(random.random()*n + 1)
while t<=m:
wanjia = int(input("你觉得兔子在几号洞口?"))
if tuzi ==1:
tuzi = tuzi + 1
elif tuzi == n:
tuzi = tuzi - 1
else:
tuzi1 = int(random.random()*2)
if tuzi1 == 0:
tuzi = tuzi + 1
else:
tuzi = tuzi - 1
if wanjia == tuzi:
print("恭喜你抓到兔子了")
break
elif t == m:
print("机会用完了")
t = t + 1
else:
print("没抓到兔子,还剩",m-t,"次机会")
t = t + 1
请输入洞口的个数:5
请输入玩家游戏次数:5
你觉得兔子在几号洞口?2
恭喜你抓到兔子了