Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


The Python not keyword is a logical operator which returns true if its operand is false and returns false if its operand is true.

Syntax

not(expression)
not(operand)           

Example:

In the below example, not keyword is used to check whether the variable x less than 5 or not.

x = 10
print (not(x > 5))

The output of the above code will be:

False

Example:

In the below example, not keyword is used to check the variable value for 'SUN' and 'SAT'. It returns True if the value is neither 'SUN' nor 'SAT'.

day = 'FRI'
print (not(day == 'SUN' or day == 'SAT'))

The output of the above code will be:

True

❮ Python Keywords