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 ) returns false
  • ( !false ) returns true
  • ( !(10 < 11) ) returns false

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

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?