Skip to content

If is true Python concept | Example code

  • by

In Python If it’s true, it will execute the code. If statement expressions are used True and False Booleans evolution in Python.

Example If is true Python

If you want to make sure that foo really is a boolean and of value True, use the is the operator. Always use it with the built-in constants True, False, and None.

foo = True
if foo is True:
    print(True)

Output:

If is true Python

Do comment if you have any doubts or suggestions on this Python basic topic.

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 *