Python if statement works on the boolean expression true and false statement. If true then the block will execute.
Python boolean if example
Simple example code Using a Boolean in an If-Statement in Python. Don’t forget capital T and F, it is case sensitive.
a = True b = False if a == True: print("a is true") if a: print("a is true") # shorthand of the above IF statement
Checks if the boolean is true python with the if-else statement.
b = True if b: print('b is True') else: print('b is False')
Output: b is True
Do comment if you have any doubts or suggestions on this Python boolean topic.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.