Learn
The not
logical operator is denoted by !
.
It reverses the bool
outcome of the expression that immediately follows.
Here’s the truth table:
a | !a |
---|---|
false | true |
true | false |
For instance:
( !true )
returnsfalse
( !false )
returnstrue
( !(10 < 11) )
returnsfalse
Note: The keyword not
can be used in the place of !
.
Instructions
1.
Write the following if
statement:
- If the user is
!logged_in
, then print the phrase"Try again"
.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.