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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -