I want to compare the values in one list to the values in a second list and return all those that are in the first list but not in the second i.e.
list1 = ['one','two','three','four','five']
list2 = ['one','two','four']
would return ‘three’ and ‘five’.
I have only a little experience with python, so this may turn out to be a ridiculous and stupid way to attempt to solve it, but this what I have done so far:
def unusedCategories(self):
unused = []
for category in self.catList:
if category != used in self.usedList:
unused.append(category)
return unused
However this throws an error ‘iteration over non-sequence’, which I gather to mean that one or both ‘lists’ aren’t actually lists (the raw output for both is in the same format as my first example)
Use sets to get the difference between the lists: