Another helpful logical operator is the π
operator.
The π
operator also checks two expressions and returns a π
value. The major difference is that the π
operator returns π
so long as a single expression is π
.
Hereβs the table of expression combinations:
Expression | Evaluates to |
---|---|
π π π |
π |
π π π |
π |
π π π |
π |
π π π |
π |
From the table above, we see that the only expression that returns π
is when both values are π
, (π π π
).
Letβs look over a code snippet using π
:
π β‘οΈπ hasUmbrella π β‘οΈπ hasRaincoat βͺοΈ hasUmbrella π hasRaincoat π π π€Walking in the rain is fun!π€βοΈ π π π π π€Let's stay insideπ€βοΈ π π Prints: Walking in the rain is fun!
Notice, hasUmbrella
has a value of π
, while hasRaincoat
has a value of π
. Our condition checks hasUmbrella π hasRaincoat
. As long as either hasUmbrella
OR hasRaincoat
is π
, it returns π
. Since Walking in the rain is fun!
was printed, we can confirm that our condition returned π
.
Instructions
Under the π π€Heads I win, Tails you loseπ€βοΈ
statement, create a βͺοΈ
statement that checks isHeads
or isTails
. Then, add its ππ
block that contains a πβοΈ
with the string: π€Looks like I winπ€
.