Python How To Negate A Boolean
When working with Python there are times where you might want to negate a boolean. This is pretty easy to do as python has built in features to handle this. You can do this by using the ‘not’ keyword.
To negate a boolean in Python just use the following example:
print(True) # prints True print(not True) # prints False print( 5 == 5 ) # prints True print( not 5 == 5 ) # Prints False
Here is an example showing how you might actually do this.
statusOK = checkDataStatus() if not statusOK: print("Error")