Python猜数字代码错误的原因是什么?
importrandomdaan=random.randint(1,10)print('开始')num=input('输入数字')n=3cai=int(num)while...
import random
daan=random.randint(1,10)
print('开始')
num=input('输入数字')
n=3
cai=int(num)
while cai!=daan and n>0:
num=input()
n-=1
if cai==daan:
print('lihai')
elif cai>daan:
print('dale')
elif cai<daan:
print('xiaole')
if n>0:
print('chongxinshuru')
else:
print('GG')
print('gg')
错误结果多运行一次猜的过程 展开
daan=random.randint(1,10)
print('开始')
num=input('输入数字')
n=3
cai=int(num)
while cai!=daan and n>0:
num=input()
n-=1
if cai==daan:
print('lihai')
elif cai>daan:
print('dale')
elif cai<daan:
print('xiaole')
if n>0:
print('chongxinshuru')
else:
print('GG')
print('gg')
错误结果多运行一次猜的过程 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询