Apr-28-2022, 04:11 PM
(This post was last modified: Apr-28-2022, 04:12 PM by deanhystad.)
Python can use anything in an if statement, not just boolean values or expressions that have a boolean result. A Python "and" or "or" may result in a non-boolean result, like a list or a string. That is why the nature of A, B and C are important in knowing how they can be used.
You could use the new (python 3.10) match statement
You could use the new (python 3.10) match statement
match control_flag: case "f1": # more tests case "fs": # more testsIf you are worried about efficiency you should not do lots of unnecessary conversions . Why int(float(datalist[2]))? You can compare a float(datalist[2]) against an int mte * 30. And I don't know if Python's code generator is smart enough to not evaluate float(datalist[6] thee times in this expression.
if float(datalist[6]) > float(datalist[3]) and float(datalist[6]) % 10 == 0 and float(datalist[6]) - float(datalist[3]) < 11: