You will use this block to define a logic expression.
To create a logic expression, you will typically compare two variables or values. This is done by using python syntax:
The conditionals logic follows python syntax. Here are some options:
Number == 4 #Check if Number is Equal to 4Number != 4 #Check if Number is Not Equal to 4Number > 4 #Check if Number is greater than 4Number < 4 #Check if Number is less than 4Number >= 4 #Check if Number is greater than or equal to 4Number <= 4 #Check if Number is less than or equal to 4
Conditionals follow python syntax and options. There are several options for strings and lists:
== #Check if strings equal!= #Check if strings not equalin #Check if string is in another string
Date comparisons in python follow the same syntax as number comparisons.
== #Check if dates equal!= #Check if dates not equal> #Check if date is after< #Check if date is before>= #Check if date is after or equal<= #Check if date is before or equal
Following python syntax, comparisons are case sensitive and will evaluate false if two strings have different capitalization. Python string methods such as .lower() and .upper() can be useful if you want to avoid case sensitivity.
Checking a variable for containing a value can be done in python by
if <var>: Similarly, with the conditional module we can check a variable containing a value by dragging it into the conditional blank:
In this example, if
sample_list contains a value, the conditional will return true.
not keyword can be used to check for the emptiness of a list or dictionary.
In this example, since
sample_list does not contain any values, our conditional expression will evaluate as true.
Conditional modules support the use of parenthesis to use an order of operations while evaluating.
Please see the "Has changed" Module for comparisons used in conjunction with "has changed" or "changed by" logic.
By pressing the + Add Condition button, you can add additional conditions.
And: Use if you want your expression to evaluate to
True only when both conditions are
Or: Use if you want your expression to evaluate to
True when at least one of your conditions are
The If branch will run if your logic expression evaluates to
The Else-If branch will run if the proceeding logic expression evaluates to
False, but the logic expression in the current Else-If branch evaluates to
The Else branch will run if all of the proceeding logic expressions evaluate to
In the above image, our variable Number is equal to 4. Since we first evaluate the left most branch ( the if statement ) we see that our Number is not greater than 10. Therefore this evaluates as false and then we move right to the Else If branch. This branch checks to see if Number is equal to 5. Since Number is 4, this evaluates as false and our else branch is True.