Python (Scripting) - Getting Started with Booleans

by
Jeremy Canfield |
Updated: June 21 2023
| Python (Scripting) articles
In Python, True and False are used to set a boolean. In this example, the if statement will only be invoked when foo = True.
#!/usr/bin/python
foo = True
if foo == True:
print("The foo boolean is True")
else:
print("The foo boolean is not True")
Or like this, using False.
#!/usr/bin/python
foo = False
if foo == False:
print("The foo boolean is False")
else:
print("The foo boolean is not False")
Did you find this article helpful?
If so, consider buying me a coffee over at