Python >= comparison operator throwing syntax error

Viewed 264

It seems my if else statement throws a syntax error. I've read up on how if statements should be written (and the other if else statements in my script work with no issues) so I am not sure why there's an issue.

if small_wh <= 5.0:
    emColor = discord.Color.red
elif small_wh <= 15.0 and >= 5.1:
    emColor = discord.Color.orange

The >= (in the elif statement) is where it states the syntax error is.

3 Answers

The second comparison of you elif statement isn’t comparing anything to 5.1.

elif small_wh <= 15.0 and small_wh >= 5.1:

You should compare 5.1 with some value, not and word, i.e. do:

elif small_wh <= 15.0 and small_wh >= 5.1:

or using python capability to combine comparisons you can do::

elif 5.1 <= small_wh <= 15.0:
if small_wh <= 5.0:
   emColor = discord.Color.red
elif small_wh <= 15.0 and small_wh >= 5.1:
   emColor = discord.Color.orange
Related