x=[1,2,3,[“skr”,“dd”]]
print([“skr”,“dd”] in x)
print(“skr” in x)
output:
True
False
can any one help why we are getting false for second print()
x=[1,2,3,[“skr”,“dd”]]
print([“skr”,“dd”] in x)
print(“skr” in x)
output:
True
False
can any one help why we are getting false for second print()
print(“skr” in x[3]) for this it is true
Hi,
Your question has the solution in it.
x=[1,2,3, [“skr”,“dd”] ]
print([“skr”,“dd”] in x) # True as it is one of the element of the list x
print(“skr” in x) # “skr” is not an element of the list so false, it is element of the 4th element [“skr”,“dd”] – x[3]
print(“skr” in x[3]) # This is where you are accessing the elements 4th elements and using in operators. so it will give True.
All the best!