新手,不知道为什么输入一个值,疯狂跳出回复
求助。。。 C:\Users\13374\Desktop 发不了照片,number=int(input("please fil in:"))while number!=8:
print("it is wrong")
if number ==8:
print("you are my only")
else:
if number>8:
print("it is too big")
else:
print("it is too small")
print("game is over")
输入比8大或者小的数之后,疯狂回复(“it is.....) 低调的小白er 发表于 2020-3-13 21:32
发不了照片,number=int(input("please fil in:"))
while number!=8:
print("it is wrong")
因为在循环里没有 input() ,只有 print(),就变成死循环了 把else改为elif,然后把if语句删掉 低调的小白er 发表于 2020-3-13 21:33
输入比8大或者小的数之后,疯狂回复(“it is.....)
改成这样:
number=int(input("please fil in:"))
while True:
if number ==8:
print("you are my only")
break
else:
if number>8:
print("it is too big")
number=int(input("please fil in:"))
continue
else:
print("it is too small")
number=int(input("please fil in:"))
continue
print("game is over") 在while循环中,你没有修改过number的值,当一开始输入number=9,则while的循环条件永远成立,进入了死循环。 因为你没有在循环里面用input让number可以重新获得一个值,所以number如果不为8就会一直不为8,在循环里一直重复执行循环内不为8的条件,打印那条语句 低调的小白er 发表于 2020-3-13 21:33
输入比8大或者小的数之后,疯狂回复(“it is.....)
有帮助就设个最佳答案吧~ qiuyouzhi 发表于 2020-3-13 21:58
有帮助就设个最佳答案吧~
不太会搞{:5_109:}...
页:
[1]