- 2

What is the use of NOT? In python?

17th Jan 2018, 4:26 AM
Amrutha
Amrutha - avatar
2 Respostas
+ 2
x = 4 if not x == 5: -> means: if x is not equal to 5 print("Yes, x is not equal to 5") # will print yes, because x is NOT equal to 5. x = 5 if not x == 5: print("Yes, x is not equal to 5") # will print nothing, because x is equal to 5.
17th Jan 2018, 5:08 AM
Dread
Dread - avatar
0
It's useful for functions that doesn't have negative form like "in". if "e" in "hello": print "e is in the word 'hello'" if "x" not in "hello": print "the letter x is not in 'hello'" Both conditionals are true.
17th Jan 2018, 6:59 AM
Sebastián Zapata
Sebastián Zapata - avatar