Last active
June 25, 2018 16:46
-
-
Save craigderington/0d03e6b2140479ad3bcb71e0748e5b96 to your computer and use it in GitHub Desktop.
De-duplicate two lists. List A contains all records. List B contains a subset of List A. Produce a clean list A NOT IN B.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# *-* coding: utf-8 *-* | |
lst_a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
lst_b = [1, 4, 5, 7, 9, 11, 14] | |
def de_duplicate(l1, l2): | |
""" | |
Return a de-duplicated list | |
:param l1: list splash visitor | |
:param l2: list gender visitor | |
:return: l3 cleaned list | |
""" | |
l3 = list() | |
for i in l1: | |
if i not in l2: | |
l3.append(i) | |
return l3 | |
if __name__ == '__main__': | |
clean_list = de_duplicate(lst_a, lst_b) | |
print(clean_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment