I'm trying to change the output of Boolean values.
For example if I've got something like:
3 == 3
def equivalence(a,b): if(a==b): print("Correct") else: print("Incorrect")
Then you can call this function.
equivalence(5,5) #This will print "Correct" equivalence(5,6) #This will print "Incorrect"
If you actually want to change what
== actually does, you would have to override the operator class
__eq__. But this can quickly become out-of-hand if you are just starting out with programming.
Edit to address OP's comment:
What I wrote can be replaced to anything. You can do something as simple as:
if(2+3<5-7): print("Correct") else: print("Incorrect")
The general format is:
if(condition): #What to do if condition is true. else: #What to do if condition is false.
You don't even need a function to do this. You can use if-statements on their own like what I did above.
Okay now I see what you want. Here's what you can do. It might be a little complex but bear with me.
Create a function such as this. You can name it whatever you want as long as you're consistent:
def booleanizer(condition): if(condition): print("Correct") return True else: print("Incorrect") return False
Now, wherever you have a conditional statement where you are trying to print "correct" or "incorrect", just wrap the conditional statement in
booleanizer as follows:
Say you have
2+3<5-7 and you want to "booleanize" it.
booleanizer(2+3<5-7) #this prints "Incorrect"
Or you could apply this to any conditional
booleanizer("This"=="This") #Prints "Correct" booleanizer(7<5) #Prints "Incorrect"