猜数字游戏代码
result = 8answer = input("来猜猜我在想的数字:")
answer1 = int(answer)
while answer1 != result:
if answer1 == result:
print("恭喜你,你真是我肚子里的蛔虫呢")
else:
if answer1 > result:
print("你可真敢猜啊,太大了呀")
answer = input("再来猜一猜吧:")
answer1 = int(answer)
else:
print("你胆子可真小,猜的太小了呀")
answer = input("再来猜一猜吧:")
answer1 = int(answer)
为什么我这段代码,当输入数字正确的时候,不会显示红色字的那句话呀
本帖最后由 Mike_python小 于 2020-5-31 20:08 编辑
你都while answer1 != result
如果答对了就跳出循环了
给你改了一下代码:
result = 8
answer = input("来猜猜我在想的数字:")
answer1 = int(answer)
while answer1 != result:
answer1 == result
if answer1 != result:
if answer1 > result:
print("你可真敢猜啊,太大了呀")
answer = input("再来猜一猜吧:")
answer1 = int(answer)
else:
print("你胆子可真小,猜的太小了呀")
answer = input("再来猜一猜吧:")
answer1 = int(answer)
print("恭喜你,你真是我肚子里的蛔虫呢")
求最佳{:10_254:} @不二如是 卡下面
我要最佳!! 或者
result = 8
answer = input("来猜猜我在想的数字:")
answer1 = int(answer)
while True:
if answer1 == result:
print("恭喜你,你真是我肚子里的蛔虫呢")
break
else:
if answer1 > result:
print("你可真敢猜啊,太大了呀")
answer = input("再来猜一猜吧:")
answer1 = int(answer)
else:
print("你胆子可真小,猜的太小了呀")
answer = input("再来猜一猜吧:")
answer1 = int(answer) Mike_python小 发表于 2020-5-31 19:44
你都while answer1 != result
如果答对了就跳出循环了
给你改了一下代码:
额……感觉你的代码有点乱……
while answer1 != result并没有循环体
answer1 == result是干嘛的? result = 8
answer = input("来猜猜我在想的数字:")
answer1 = int(answer)
while answer:
if answer1 == result:
print("恭喜你,你真是我肚子里的蛔虫呢")
break
else:
if answer1 > result:
print("你可真敢猜啊,太大了呀")
answer = input("再来猜一猜吧:")
answer1 = int(answer)
else:
print("你胆子可真小,猜的太小了呀")
answer = input("再来猜一猜吧:")
answer1 = int(answer)
result = 8
answer = input("来猜猜我在想的数字:")
answer1 = int(answer)
while answer1 != result:
if answer1 > result:
print("你可真敢猜啊,太大了呀")
answer = input("再来猜一猜吧:")
answer1 = int(answer)
else:
print("你胆子可真小,猜的太小了呀")
answer = input("再来猜一猜吧:")
answer1 = int(answer)
print("恭喜你,你真是我肚子里的蛔虫呢") 你那个while 后面限定了条件
Mike_python小 发表于 2020-5-31 19:44
你都while answer1 != result
如果答对了就跳出循环了
给你改了一下代码:
{:7_142:} Mike_python小 发表于 2020-5-31 19:44
你都while answer1 != result
如果答对了就跳出循环了
给你改了一下代码:
{:10_278:}刚到鱼吧,不好意思,看错楼层了,你这个是我想设置的最佳{:10_262:} 美梦与热望 发表于 2020-5-31 20:05
刚到鱼吧,不好意思,看错楼层了,你这个是我想设置的最佳
no 我@一下版主
让他改一下
我真的很缺最佳{:10_266:}@不二如是 @不二如是 看9楼
我是最佳呀
我很缺最佳的{:10_266:}
页:
[1]