Boolean logic | Sololearn: Learn to code for FREE!


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”)

2/22/2018 10:35:39 PM

Sulaiman Bada

4 Answers

New Answer


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!'.


Try using the not (!) operator, like this: if (!(2==3)){ print("Hello") }


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")


if 2 != 3: print("hello")