main_list = [[‘livingroom’, ‘Entrance’, ‘livingroom’, ‘bedroom’, ‘kitchen’, ‘bathroom’],
[‘bedroom’, ‘Entrance’, ‘livingroom’, ‘bathroom’, ‘livingroom’, ‘kitchen’],
[‘bedroom’, ‘Entrance’, ‘bathroom’, ‘bathroom’, ‘livingroom’, ‘livingroom’, ‘bathroom’, ‘livingroom’, ‘bedroom’, ‘kitchen’],
[‘bedroom’, ‘Entrance’, ‘bathroom’, ‘bathroom’, ‘bathroom’, ‘kitchen’, ‘livingroom’, ‘livingroom’, ‘bedroom’, ‘bathroom’]]
neighbors = [[‘Entrance’, ‘bedroom’, ‘livingroom’], [‘livingroom’, ‘livingroom’, ‘kitchen’, ‘Entrance’], [‘Entrance’, ‘bathroom’, ‘livingroom’], [‘livingroom’, ‘kitchen’, ‘bedroom’], [‘Entrance’, ‘bedroom’, ‘bathroom’, ‘kitchen’], [‘livingroom’, ‘kitchen’, ‘bathroom’],
[‘Entrance’, ‘livingroom’, ‘bedroom’], [‘bedroom’, ‘bathroom’, ‘Entrance’], [‘bedroom’, ‘bathroom’, ‘livingroom’], [‘Entrance’, ‘livingroom’, ‘livingroom’, ‘bathroom’], [‘bathroom’, ‘kitchen’, ‘livingroom’], [‘livingroom’, ‘kitchen’],
[‘Entrance’, ‘bathroom’, ‘livingroom’, ‘bedroom’], [‘bedroom’, ‘bathroom’, ‘livingroom’, ‘Entrance’], [‘bedroom’, ‘bathroom’, ‘bathroom’], [‘Entrance’, ‘livingroom’, ‘bedroom’, ‘bathroom’], [‘Entrance’, ‘livingroom’, ‘livingroom’, ‘livingroom’], [‘bedroom’, ‘livingroom’, ‘bathroom’, ‘livingroom’], [‘bathroom’, ‘livingroom’, ‘bathroom’], [‘bathroom’, ‘livingroom’, ‘kitchen’, ‘livingroom’], [‘bathroom’, ‘kitchen’, ‘bedroom’], [‘livingroom’, ‘bedroom’, ‘kitchen’],
[‘Entrance’, ‘bathroom’, ‘bathroom’, ‘bedroom’], [‘bedroom’, ‘bathroom’, ‘Entrance’], [‘bedroom’, ‘kitchen’, ‘livingroom’, ‘bathroom’], [‘Entrance’, ‘bathroom’, ‘livingroom’, ‘bathroom’], [‘bedroom’, ‘bathroom’, ‘kitchen’, ‘bathroom’], [‘bathroom’, ‘bathroom’, ‘bedroom’, ‘kitchen’], [‘bathroom’, ‘bathroom’, ‘livingroom’], [‘bathroom’, ‘bedroom’, ‘livingroom’], [‘kitchen’, ‘livingroom’, ‘bedroom’], [‘livingroom’, ‘bathroom’]]
each item in main list in each sublist in neighbors check if the last item in each sublist in neighbors is ‘livingroom’ and other item in sublist is ‘bedroom’ find the place of this last item in main list and remove it
I want this output: [[‘Entrance’, ‘livingroom’, ‘bedroom’, ‘kitchen’, ‘bathroom’],
[‘bedroom’, ‘Entrance’, ‘bathroom’, ‘livingroom’, ‘kitchen’],
[‘bedroom’, ‘Entrance’, ‘bathroom’, ‘bathroom’, ‘livingroom’, ‘bathroom’, ‘livingroom’, ‘bedroom’, ‘kitchen’],
[‘bedroom’, ‘Entrance’, ‘bathroom’, ‘bathroom’, ‘bathroom’, ‘kitchen’, ‘livingroom’, ‘bedroom’, ‘bathroom’]]