Python Tutorial Python Advanced Python Resources Python Libraries
Python Java C++ C C# PHP R SQL DS Algo InterviewQ

Python not Keyword



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 example below, 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 example below, 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

5