I have a list that containts a tuple, and that tuple contains another list with values:
list
[('5c3b542e2fb59f2ab86aa81d',
['hello', 'this', 'is', 'a', 'test', 'sample', 'this', 'is', 'duplicate'])]
As you can notice 'this and 'is' are already present in this list and I would like to remove them.
So I want something like this:
new_list
[('5c3b542e2fb59f2ab86aa81d',
['hello', 'this', 'is', 'a', 'test', 'sample', 'duplicate'])]
Just to be clear, the List above contains multiple values, see my screenshot attached to this question.
So far I tried the following method:
final_list = []
for post in new_items:
if post[1] not in final_list:
_id = post[0]
text = post[1]
together = _id, text
final_list.append(together)
I tried to loop through each item in the list and if it's not in the list, it would be added to the final_list. But so far this method doesn't work and gives me the exact same list back.