if my_variable == "abc":
    print("Yes")

if (my_variable_a == "abc") and (my_variable_b>= 2.0):
    print("Yes")


if my_variable == 1:
    print("Yes1")
elif my_variable  < 2:
    print("Yes2")
elif (my_variable  < 3):
    print("Yes3")
else:
    print("No")
Multiline if

Not a problem, you can use whitespace as in C:

if (
    (my_variable_a == "abc") or
    (my_variable_b == "xyz")
    ):
    print("Yes")

Boolean operators

NOT Equal
if not something_a == 2:
    print("No")

if not(something_a== 2):
    print("No")
Logical AND
if (my_variable == 2) and (my_variable == 4):
Logical OR
if (my_variable == 2) or (my_variable == 4):
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *