Skip to Content

The operator ! changes the Boolean value of a variable, expression or returned function’s value to the other side.

This can be quite handy when determining if the value of something is false (or not true).

However, this operator by itself does not work in Python code. It can be used in JavaScript, but just not in Python.

The equivalent in Python is using the operator not.