多一次没判断的输入,怎么改,只想要三次输入
import randomsecret = random.randint(0,10)
print(secret)
temp=input("请输入小甲鱼心中猜测的数字:")
i=1
guess=int(temp)
if secret ==guess :
print("卧槽,你是小甲鱼心里的蛔虫吗")
print("猜对也没奖励!!!" )
while guess != secret and i<=3:
if guess>secret :
if i==4:
break
else :
i=i+1
print("哥,大了大了!!!")
temp=input("请重新输入:")
guess=int(temp)
else :
if i==4:
break
else :
i=i+1
print("哥,小了小了!!!")
temp=input("请重新输入:")
guess=int(temp)
print("游戏结束!!!")
循环外有一次,循环中3次,所以总共4次。
while guess != secret and i<=3:
改为
while guess != secret and i<=2:
或
while guess != secret and i<3: 冬雪雪冬 发表于 2020-2-7 17:06
循环外有一次,循环中3次,所以总共4次。
while guess != secret and i
谢谢{:10_297:}
页:
[1]