0
Boolean NoT operator Python
if not True : print ("1") elif not (1+1==3): print("2") else: print("3") Why did we use if not True: print("1") What is the use of coding it in the program, because when we compile it separately we get no output
3 Respostas
+ 1
Yukthamukhi Rudra
This thing is self explanatory 😃😃
If something is not True, then it's False. If not True is used to make you do some work to know that the statement is False. Therefore, anything under a False statement will not be run, that's why you get no output.
Hope this helps 😃😃
0
"if not True" always returns False, so indeed the snippet has no effect during runtime.
However, even though it may not be a good practice, you can use this kind of code to temporarily disable the following codes, which can be useful during debugging.
e.g.
if False:
(some code you want to disable temporarily)
0
Thanks Tomiwa and Panko:) That's was helpful :)