notEasy Examples

Logical NOT operator; inverts a boolean value

Logical negation

Inverting boolean values with not.

python
print(not True)
print(not False)

# Negating conditions
x = 5
if not x > 10:
    print("x is not greater than 10")

# Checking absence
fruits = ["apple", "banana"]
if "cherry" not in fruits:
    print("No cherry available")

# not with falsy values
print(not 0)
print(not "")
print(not None)
print(not [])
Expected Output
False
True
x is not greater than 10
No cherry available
True
True
True
True

'not' returns True if the value is falsy, False if truthy. It always returns a boolean, unlike 'and' and 'or'.

Want to try these examples interactively?

Open Easy Playground