list_of_lists = [['g', 'h', 'i'], ['a', 'b', 'c'] ... ]]
first_list = ['i', 'am', 'an', 'old', 'man']
myList = []
for current_list in list_of_lists:
for item in current_list:
for word in first_list:
if item in word:
myList.append(item)
list_of_lists.remove(item)
I edited your code so it would read more sensibly, to me, so I can think I know what you're trying to do.
In my mind, you are reading through a list, from within a set of lists to check to see if an item from that "sublist" is in another list (first_list).
If the item is in one of the words in first list, you are trying to remove the "sublist" from list_of_lists, correct? If so, that's where you are getting your error. Say you are on the first iteration of the set of lists, and you are checking to see if the letter "i" from the first sublist in list_of_lists is in the first word from first_list. It should evaluate to true. At that point, you are then telling Python the following in plain english, "Python, remove the item from list_of_lists that has a value of i." However, because list_of_lists contains lists, that won't work, because none of the values within list_of_lists are strings, just lists.
What you need to do is specify the list you are currently iterating on, which will be represented by current_list in the above code.
So maybe instead of
list_of_lists.remove(item)
or rather in your code
match_list.remove(j)
try
list_of_lists.remove(current_list)
or rather in your code
match_list.remove(i).
I have a feeling you are going to experience other errors with the iterations that will likely remain in some scenarios if you get another match, but that's not the problem you're having now....