你直接复制代码上来,不用压缩包
好了! 其实只要把secref改为secret就可以了
你对比一下:
你源代码:
import random
times = 3
secref = random.randint(1,10)
print("------------我爱鱼C工作室-----------------")
guess = 0
print("不妨猜一下小甲鱼现在心里想的那个数字:", end="")
while (guess != secret) and (times > 0):
temp = input()
if temp.isdigit():
guess = int(temp)
if guess == secret:
print("我擦,你是小甲虫心里的蛔虫吗?!")
print("哼,猜对了也没有奖励!")
else:
if guess > secret:
print("哥,大了大了~~~~")
else:
print("嘿,小了,小了~~~~~")
if times > 1:
print("再试一次吧: ", end="")
else:
print("机会用完喽")
else:
print("抱歉, 你的输入有误,请输入一个整数: ",end="")
times = times - 1 # 用户每输入一次, 可用机会就-1
print("游戏结束,不玩了")
我改的:
import random
times = 3
secret = random.randint(1,10)
print("------------我爱鱼C工作室-----------------")
guess = 0
print("不妨猜一下小甲鱼现在心里想的那个数字:", end="")
while (guess != secret) and (times > 0):
temp = input()
if temp.isdigit():
guess = int(temp)
if guess == secret:
print("我擦,你是小甲虫心里的蛔虫吗?!")
print("哼,猜对了也没有奖励!")
else:
if guess > secret:
print("哥,大了大了~~~~")
else:
print("嘿,小了,小了~~~~~")
if times > 1:
print("再试一次吧: ", end="")
else:
print("机会用完喽")
else:
print("抱歉, 你的输入有误,请输入一个整数: ",end="")
times = times - 1 # 用户每输入一次, 可用机会就-1
print("游戏结束,不玩了")
你用的图片看不好,那我就用我的代码
import random as r
s=r.randint(1,10)
print('-----------------------------------我爱鱼C工作室--------------------------------')
g=int(input('不妨猜一下小甲鱼现在心里想的是哪个数字:'))
if g==s:
print('''我草,你是小甲鱼心里的蛔虫吗?!\n哼,猜中了也没有奖励!''')
else:
for i in range(3):
if g==s:
print('''我草,你是小甲鱼心里的蛔虫吗?!\n哼,猜中了也没有奖励!''')
break
elif g>s:
print('哥,大了大了~~')
else:
print('嘿,小了,小了~~')
g=int(input('哎呀,猜错了,请重新输入吧:'))
else:
if g==s:
print('''我草,你是小甲鱼心里的蛔虫吗?!\n哼,猜中了也没有奖励!''')
else:
print('很遗憾,3次机会都用光了,你还没答对,下次再来T_T')
print("游戏结束,不玩了*_*") 第一眼看错误说的是没有定义,那么就去找什么没有定义,一看就看到了,前面的尾巴是f,你后面用的是t,所以报错了 好的,谢谢大家了 zhuhong 发表于 2020-7-29 18:45
上帝看不下去了,教会了,我怎么截图
https://jingyan.baidu.com/article/3c48dd342644aaa10ae358d0.html
页:
1
[2]