python - How can I check if one list is a subset of the another? -
here current code have:
a = input('enter words: ') b, c = a.split() q = [] z = [] in b: q.append(i) j in c: z.append(j) letters in q: if letters in z: print('yes')
it output 'yes'
if letter
in q
in z
.
is there someway check if instances of characters in 1 list in another. like:
for letters in q: if letters in z: #all print('yes')
i believe want:
if all(letter in z letter in q): print('yes')
simplified full working code:
q, z = input('enter words: ').split() if all(letter in z letter in q): print('yes')
sample runs:
$ python test.py enter words: cat tack yes $ python test.py enter words: cat bat
Comments
Post a Comment