I have two lists:
a= [['tea','apple',1,1],['coffee','apple',0,1],['cola','mango',1,1],['lemon','banana',0,0]]
b=[[ 'apple','0','1','1','3'],[ 'ring','0','1','1','3'],[ 'tennis','1','0','0','3'],[ 'mango','0','1','0','3']]
I am trying to figure out the best possible way to :
- List item
- Locate/search the the common elements between : a and b in list a ( i.e. apple and mango in list a).
- For number of entries of e.g. apple in list a, I would like to add entire
[ 'apple','0','1','1','3']
to list b. If there are 2 apple entries in list a then I would like to add two['apple',...]
blocks in b.The list be should look something like :b=[[ 'apple','0','1','1','3'],[ 'apple','0','1','1','3'],[ 'mango','0','1','0','3']]
Is there any easier way to do this?