【发布时间】:2018-01-23 21:05:17
【问题描述】:
if score <=30:
print = "You have scored:" + score + ":("
else score > = 31 and < = 60
print = "You have scored:" + score + ":/"
elif score < = 61
print = "You have scored:" + score + ":)"
我正在用 python 进行测验,我需要它,以便当分数在 0-30,30-60 和 60+ 之间时,会显示不同的消息,尽管我尝试了上面的代码并且它一直说语法无效.
【问题讨论】:
-
elif score >= 31 and score <= 60而不是else score > = 31 and < = 60 -
elif条件后还需要冒号 -
它继续说无效的语法
-
你还需要
elif score >= 31 and score <= 60。这是两个独立的条件检查。
标签: python