i =1
temp = input("不妨猜下我现在心里想哪个数字:")
guess = int(temp)
while guess !=8 and i<3:
if guess == 8:
print("你猜对了")
print("猜中了也没有奖励")
else:
if guess > 8:
print("大了大了")
else:
print("小了小了")
temp = input("重新猜下吧:")
guess = int(temp)
i=i+1
print("游戏结束")
temp = input("猜数字")
guess = int(temp)
if guess == 8:
print ("对了")
else:
if guess > 8:
print("大了")
else:
print("小了")
i = 3
while guess != 8 and i>0:
i = i-1
temp = input("猜数字")
guess = int(temp)
if guess == 8:
print ("对了")
else:
if guess > 8:
print("大了")
else:
print("小了")
print("结束")
我也是看的小甲鱼视频学习的~
temp = input("不妨猜一下小甲鱼心里想的是哪个数字:")
guess = int(temp)
if guess == secret:
print("我草,你是小甲鱼心里的蛔虫吗?")
print("哼,猜中了也没有奖励!")
else:
if guess > secret:
print("哥,大了大了!")
else:
print("嘿,小了小了!")
i=2
while guess != secret and i>0:
i =i-1
temp = input("哎呀,猜错啦!请重新输入吧:")
guess = int(temp)
if guess == secret:
print("我草,你是小甲鱼心里的蛔虫吗?")
print("哼,猜中了也没有奖励!")
else:
if guess > secret:
print("哥,大了大了!")
else:
print("嘿,小了小了!")
print("游戏结束,不玩啦")
这个可以无限循环吧,只要不输入8