lists = [['1. what is your name','alice','what is your age','98'],
['2. how old are you','24','city of birth','washington 3. None what is your fav subject?'],
['3. what is your fav subject? please choose from maths, english, science','maths','school','elemetary oak']
]
i have the above list of lists, i would like to remove ‘3. None what is your fav subject?’ from the the second list by seeing whats in common with the first element from next list.
i have tried:
import itertools
for x,y in zip(lists, itertools.islice(lists, 1, None)):
if x[2] != y[0]:
print("CHECKING")
new_str = ''.join([i for i in x[2] if i in y[0]])
print("RESULT===============",new_str)
but this return: washington 3. one what is your fav subject?
i need it to just be washington
how can i iterate through a list of lists and check if last element of last list contains anything in common with first sentence in next list and then remove whats in common from the last element?