Can anyone help me understand it? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
+ 1

# Can anyone help me understand it?

If not True: Print("1") elif not ("1+1== 3"): Print ("2") else: Print("3") The NOT Boolean is quit confusing for me.😣😵😵 The answer is 2 how??

18th Apr 2021, 1:12 PM
7 ответов
+ 3
Your code has case and indention errors. Corrected: if not True: print("1") elif not ("1+1== 3"): print ("2") else: print("3") Output is 3. If you remove the quotes in the elif condition it will output 2. not True -> False "1+1==3" -> True (it is a string and not empty) 1+1==3 -> 2==3 -> False
18th Apr 2021, 1:45 PM
Benjamin Jürgens
+ 2
not True means false. As first if is False it jumps to next elif . In elif 2==3 which is False but before False there is a not that makes it True . So 2 is printed
18th Apr 2021, 1:21 PM
TOLUENE
+ 1
Hi! is this the full code of your program? if so, the result will be 3, not two as you indicated
18th Apr 2021, 1:20 PM
Yaroslav Vernigora
+ 1
Hi there, this is the code https://code.sololearn.com/cl6RCLRvc196/?ref=app And I understand that not True is False but why is the answer not 1 , I mean there is not any information to say that it will be False or True in certain condition. Sorry, if I am not clear😅
18th Apr 2021, 1:46 PM
+ 1
18th Apr 2021, 1:50 PM