猜字谜游戏bug修复
还记得我们在python的while循环的那一节当中开发了一个简单的猜字游戏实例吗?在示例解析当中,我们提到了游戏代码中有一个bug,不知道大家尝试修复了没有,现在鄙人就将修复完的代码发布到这里:
import random
md = random.randint(0,100)
start = 0
end = 100
inp = int(input('从%s到%s猜一个数字:' %(start, end)))
while start > inp or end < inp:
inp = int(input('请重新输入从%s到%s猜一个数字:' %(start, end)))
while start <= inp <= end:
if inp < md:
start = inp
inp = int(input('从%s到%s猜一个数字:' %(start,end)))
while start > inp or end < inp:
inp = int(input('请重新输入从%s到%s猜一个数字:' %(start, end)))
elif inp > md:
end = inp
inp = int(input('从%s到%s猜一个数字:' %(start,end)))
while start > inp or