+ 3
Boolean logic
What is a wanted a false statement to execute a task how would i go about that? Like if (2==3) Print(âhelloâ)
4 Answers
+ 5
Maybe I'm miss-reading the question but, the condition isn't really false if you use the not operator. It is still true (NOT false).
You would need to use an else statement to assure a different path is taken when the condition is false.
if (2 == 3)
print("Hello")
else
print("Not equal!")
Output: Not equal!
2 == 3 is false, so the else statement executes which prints 'Not equal!'.
+ 6
Try using the not (!) operator, like this:
if (!(2==3)){
print("Hello")
}
+ 6
to decide weather true or false
it should have condition
like
if not true: # becoze no condition not going to print
print ("true 0")
elif (2+2<5): #this will print becoze condition
print("true 1")
else: # this will not print becoze first elif was right
print("true 2")
+ 5
if 2 != 3:
print("hello")