Skip to content

Python if not Boolean | Example code

  • by

Using if not Boolean will do a negation of a boolean is the opposite of its current value. A boolean is a primitive data type and its value can be True or False only.

Simple If value is False, not value would be True, and the statement(s) in if-block will execute would be True.

Or If the value is True, not the value would be False, and the statement(s) in if-block will not execute.

Python if not Boolean Example

The statements inside if block execute only if the boolean value is False.

a = False

if not a:
	print('a is false.')

Output:

Python if not Boolean

Do comment if you have any doubts and suggestions on this Python boolean code.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Your email address will not be published. Required fields are marked *