Searchâ€¦
Conditionals
Choose a branch of logic based on a condition.
For an overview on conditionals in WayScript, refer to the Introduction to Conditionals.

# â€‹ Condition Block

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:
Default is True, leaving True will result in the statement always evaluating to True so the if side of the conditional above will execute. False is also a valid input which results in the else side executing.

## â€‹ðŸ”¢ Number Comparison Options

The conditionals logic follows python syntax. Here are some options:
1
Number == 4 #Check if Number is Equal to 4
2
Number != 4 #Check if Number is Not Equal to 4
3
Number > 4 #Check if Number is greater than 4
4
Number < 4 #Check if Number is less than 4
5
Number >= 4 #Check if Number is greater than or equal to 4
6
Number <= 4 #Check if Number is less than or equal to 4
Copied!

## â€‹ðŸ”¤ Text Comparison Options

Conditionals follow python syntax and options. There are several options for strings and lists:
1
== #Check if strings equal
2
!= #Check if strings not equal
3
in #Check if string is in another string
Copied!

## â€‹ðŸ“† Date Comparison Options

Date comparisons in python follow the same syntax as number comparisons.
1
== #Check if dates equal
2
!= #Check if dates not equal
3
> #Check if date is after
4
< #Check if date is before
5
>= #Check if date is after or equal
6
<= #Check if date is before or equal
Copied!

## â€‹ðŸ”  Case Sensitive

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 for Values

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.
The `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.

## â€‹âž• Parenthesis

Conditional modules support the use of parenthesis to use an order of operations while evaluating.
Returns True since both variables contain a value and one condition is met in the first set of parenthesis.
â€‹

## â€‹ðŸ“ˆ "Changed By" Comparisons

Please see the "Has changed" Module for comparisons used in conjunction with "has changed" or "changed by" logic.

# â€‹âž• Adding Multiple Conditions

By pressing the + Add Condition button, you can add additional conditions.

## â€‹ðŸ’¡ Logical Operators

• And: Use if you want your expression to evaluate to `True` only when both conditions are `True`.
• Or: Use if you want your expression to evaluate to `True` when at least one of your conditions are `True`.

# â€‹ If / Else-If / Else

The If branch will run if your logic expression evaluates to `True`.
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 `True`.
The Else branch will run if all of the proceeding logic expressions evaluate to `False`.
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.