can someone help me to solve this?
if (bnb_spent) >= 0.00001 and (bnb_spent) <= 0.00004:
# LOG.info(f'Nasrat, čislo je menší')
pass
else:
if (bnb_spent) >= 0.0003 and (bnb_spent) <= 0.0005:
send_message1(message)
else:
if (bnb_spent) >= 0.08 and (bnb_spent) <= 0.1:
send_message2(message)
else:
if (bnb_spent) >= 0.11 and (bnb_spent) <= 0.4:
send_message3(message)
TypeError: '>=' not supported between instances of 'str' and 'float'
I expect it to send a message if the number is not less than 0.001 but at the same time is not greater than 0.003
Your bnb_spent
parameter is a string when that part of code is executed. Try casting it to a float before comparing. You could try for example (also cleaned the if-else a bit):
bnb_spent = float(bnb_spent)
if (bnb_spent) >= 0.00001 and (bnb_spent) <= 0.00004:
# LOG.info(f'Nasrat, čislo je menší')
pass
elif (bnb_spent) >= 0.0003 and (bnb_spent) <= 0.0005:
send_message1(message)
elif (bnb_spent) >= 0.08 and (bnb_spent) <= 0.1:
send_message2(message)
elif (bnb_spent) >= 0.11 and (bnb_spent) <= 0.4:
send_message3(message)