x = 10
if not x:
print("True")
else:
print("False")
arr = ['a','b','c','d','e','f']
if 'g' not in arr:
print('g is not in the list')
li = [1,2,'a','b']
if 'hello' not in li:
print('hello is not in the list')
#Example of usage of python "in" and "not in"
myVar = "Hello Green"
if "H" in myVar:
print("H is in the string")
elif "H" not in myVar:
print("H is not in strng")
# False
print(not(1 == 1))
# True
print(not(1 == 2))
result is not None
x is not y
x != y
exactly on which containers can the in operator be applied?
Generally the rule of thumb is (not a fact but a doctrine):
if container is iterable => in can be applied
ex. of such containers- (str, list, tuple, set and dict)
#note1:
by iterable i mean we can iterate like this:
for x in list_object: or for y in dict_obj:
#note2:
not in operator just have opposite definition to that of in
but above rule of thumb is true for not in as well ofcourse.