Bootstrap FreeKB - Python (Scripting) - Getting Started with Booleans
Python (Scripting) - Getting Started with Booleans

Updated:   |  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 Buy Me A Coffee



Comments


Add a Comment


Please enter 121049 in the box below so that we can be sure you are a human.