I have a question
say I have two list, and each of them contains couple of strings
a = ['x', 'y', 'z', 't'] b = ['xyz', 'yzx', 'xyw']
I want to delete xyw
in list b, because w
is not in list a
.
I tried
for s in a:
k = [t for t in b if t.find(s)]
but it didn't work Does anyone know how to do this in Python? Thank you!