Assume there are two lists A=[[1,2,3],[4,5,6],[7,8,9],[10,11,12]] and B=[[1,2,3],[5,6,4],[7,1,9]]. I want to compare these two lists and return yes if any sub list of B is in A and if not return no. Also, I want 2nd sublist of B which is [5,6,4] returns yes since it has all items of 2nd sub list of A which is [4,5,6].
Therefore, output should be like below:
yes
yes
no
This is the code:
A=[[1,2,3],[4,5,6],[7,8,9],[10,11,12]]
B=[[1,2,3],[5,6,4],[7,1,9]]
for i in range(len(B)):
if B[i] in A:
print('yes')
else:
print('no')
Aucun commentaire:
Enregistrer un commentaire