Python:Conditional';如果';设置费率的语句

Python:Conditional';如果';设置费率的语句,python,Python,我正在制作一个游戏,用户必须射杀来袭的敌人 我试图通过检查当前分数来提高敌人繁殖的速度。然而,我不断得到一个错误 这是我的密码: for x in range(score): if score is > 5 and < 10: spawnrate = 6 elif score is > 10 and < 20: spawnrate = 8 elif score is > 20:

我正在制作一个游戏,用户必须射杀来袭的敌人

我试图通过检查当前分数来提高敌人繁殖的速度。然而,我不断得到一个错误

这是我的密码:

 for x in range(score):

     if score is > 5 and < 10:
           spawnrate = 6
     elif score is > 10 and < 20:
           spawnrate = 8
     elif score is > 20:
           spawnrate = 10
范围内x的
(分数):
如果得分大于5且小于10:
产卵率=6
elif评分>10且<20:
产卵率=8
elif评分>20分:
产卵率=10

不正确,虽然可以将比较链接在一起,但这样做也不正确

使用其中一个

if 5 < score < 10:
如果5分<10分:
或者(更明确地说)

如果5分<10分:

不正确,虽然可以将比较链接在一起,但这样做也不正确

使用其中一个

if 5 < score < 10:
如果5分<10分:
或者(更明确地说)

如果5分<10分:

Remove
,必须使用变量两次

 if score > 5 and score < 10:
       spawnrate = 6
 elif score > 10 and score < 20:
       spawnrate = 8
 elif score > 20:
       spawnrate = 10
如果分数>5且分数<10:
产卵率=6
elif评分>10且评分<20:
产卵率=8
elif评分>20分:
产卵率=10

Remove
,必须使用变量两次

 if score > 5 and score < 10:
       spawnrate = 6
 elif score > 10 and score < 20:
       spawnrate = 8
 elif score > 20:
       spawnrate = 10
如果分数>5且分数<10:
产卵率=6
elif评分>10且评分<20:
产卵率=8
elif评分>20分:
产卵率=10
行:

elif score > 10 and score < 20:
elif评分>10分,评分<20分:
应该是:

elif score > 10 and score < 20:
elif评分>10分,评分<20分:
此外,python允许您执行以下操作:

elif 10 < score < 20:
elif 10
行:

elif score > 10 and score < 20:
elif评分>10分,评分<20分:
应该是:

elif score > 10 and score < 20:
elif评分>10分,评分<20分:
此外,python允许您执行以下操作:

elif 10 < score < 20:
elif 10
您可以让
if
-cases级联,而不是测试每个case的高低值,如

if score < 5:
    spawnrate = 4
elif score < 10:
    spawnrate = 6
elif score < 20:
    spawnrate = 8
else:
    spawnrate = 10
如果分数<5:
产卵率=4
elif评分<10分:
产卵率=6
elif评分<20分:
产卵率=8
其他:
产卵率=10

您可以让
if
-cases级联,而不是测试每个case的高低值,如

if score < 5:
    spawnrate = 4
elif score < 10:
    spawnrate = 6
elif score < 20:
    spawnrate = 8
else:
    spawnrate = 10
如果分数<5:
产卵率=4
elif评分<10分:
产卵率=6
elif评分<20分:
产卵率=8
其他:
产卵率=10

什么错误?您是否收到错误消息-然后添加全文。为什么要对
循环使用
?如果
分数
等于10或20会发生什么?什么错误?您是否收到错误消息-然后添加全文。为什么要对
循环使用
?如果
得分
等于10或20,会发生什么情况?