Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
listA = ["d","a","b","c"]
listB = ["e","b","c"]
def extract_not_exist(list_a, list_b):
# forでなんとか抽出する方法
not_exist_items = []
for item in list_a:
if not (item in list_b):
return sorted(not_exist_items)
# setで抽出する方法
return list(set(list_a) - set(list_b))
print set(listA) - set(listB)
print extract_not_exist(listA,listB)
set(['a', 'd'])
['a', 'd']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.