What is this? List=[1,2,3] print(3 not in List) print(not 3 inList) | Sololearn: Learn to code for FREE!
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.

18th Jul 2018, 3:45 AM
ADITYA SINHA
ADITYA SINHA - avatar
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.
18th Jul 2018, 4:16 AM
Satyam
+ 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.
18th Jul 2018, 11:40 AM
Maninder $ingh
Maninder $ingh - avatar