0
What is this? List=[1,2,3] print(3 not in List) print(not 3 inList)
Tell the difference of 2 print statements in my question.
2 Respuestas
+ 4
print (3 not in List)
This prints True if 3 is not in Lisy but as 3 IS in List, it prints False in this case.
print (not 3 in List)
This at first checks if 3 is in List. In this case 3 is in the List. Then not returns the opposite of the correct boolean value. So it return the opposite of True, False. And False gets printed.
+ 1
3 not in list=but 3 is in list so output is False.
not 3 in list=but 3 in list so output is False.
they are same not different.
let take real world example.
you are not a programmer=but am a programmer. so it is False.
not you are a programmer=but am a programmer. so it is False.