Okay, I have two lists, List 1 and List 2. I want to find all of the items that are in both list 1 and list 2, and remove them from list 1. The first way I've thought about doing this is looping through list 1 and then looping through list 2 to see if it is in list 2 but that seems slow and inefficient when scaled up. Is there a more efficient way of doing this?
Also, these lists will be ordered alphabetically (they're strings), if that helps anything.
I'm using python, but I'm also wondering from a general programming perspective.
list1 = ['bar','foo','hello','hi']
list2 = ['alpha','bar','hello','xam']
list1 would become ['foo','hi']
list(set(list1) - (set(list1) & set(list2))).