Keywords and Expressions
not — Logical negation
Truth-test an operand and invert its Boolean result. Unlike and and or, not always produces a bool. Comparisons bind more tightly than not, while and and or bind less tightly. The compound comparison operators not in and is not have their own comparison syntax. Logical not is not the bitwise complement operator ~.
Formal Syntax & Structure
python syntaxpython
not operandParameters & Attributes
| Name | Type | Description |
|---|---|---|
| operand | object | Value to truth-test. |
Return Value
bool
True for a falsy operand; False for a truthy operand.
Working Example
Example Snippetpython
items = []print(not items)print(not 5 > 3)print(not not "hello")