I want to check if all elements of a list are not present in a string.
ex :
l = ["abc","ghi"]
s1 = "xyzjkl"
s2 = "abcdef"
So , when l is compared with s1 it should return True,
when l is compared with s2 it should return False.
This is what i tried :
all(x for x in l if x not in s1) = True
all(x for x in l if x not in s2) = True
I am getting True for both cases, But it should be false in second case.
Can someone please help, any solution will help, i just want to have it in a single line.
Thanks,
>Solution :
If the goal is:
Check that all elements of a list are not present in a string.
The pattern should be: all(s not in my_string for s in input_list)
l = ["abc","ghi"]
s1 = "xyzjkl"
s2 = "abcdef"
print(all(s not in s1 for s in l)) # True
print(all(s not in s2 for s in l)) # False