The first code you have 3 lists: black list (list1), newdata (list2) and good (list3), you take the newdata exclude the items that match the items on blacklist and put the result on "good"
On the second code you have a list and a text, for each line you check if the line contains the text, if...