看书自学的纯小白第一个求助
score = int(input())while score <= 100:
if 100 >= score >= 90:
print('great')
elif 90 > score >= 85:
print('good')
elif 85 > score >= 60:
print('well')
elif 60> score >= 0:
print('come on')
else:
print('false')
temp = input('go on')
按照小甲鱼《零基础入门学习python》p4_3.py,例子,只能运行一次,如果想要循环运行,自己想了一个命令,可以循环,但出现了第一次结果正确,后续无论输入多少数值,都显示第一次运行的结果,如下面:
= RESTART: C:\Users\admin\AppData\Local\Programs\Python\Python38\3.101可循环但不显示正确结果.py
30
come on
go on60
come on
go on100
come on
go on95
come on
go on
求大神解惑 改成这样:
score = 0
while score <= 100:
score = int(input('go on'))
if 100 >= score >= 90:
print('great')
continue
elif 90 > score >= 85:
print('good')
continue
elif 85 > score >= 60:
print('well')
continue
elif 60> score >= 0:
print('come on')
continue
else:
print('false')
continue
continue 多谢各位 qiuyouzhi 发表于 2020-3-11 09:45
改成这样:
根据你的,我又自己学习了下,发现以下两段也可以,
score = 0
while score <= 100:
score = int(input('go on'))
if 100 >= score >= 90:
print('great')
elif 90 > score >= 85:
print('good')
elif 85 > score >= 60:
print('well')
elif 60> score >= 0:
print('come on')
else:
print('false')
另一个是
if 100 >= score >= 90:
print('great')
continue
elif 90 > score >= 85:
print('good')
continue
elif 85 > score >= 60:
print('well')
continue
elif 60> score >= 0:
print('come on')
continue
else:
print('false')
continue
有什么区别么?敬请答疑,多谢 rb2448 发表于 2020-3-11 10:22
根据你的,我又自己学习了下,发现以下两段也可以,
score = 0
while score = score >= 90:
没有的,但如果continue用不好可能会死循环
页:
[1]