Skip to content

Instantly share code, notes, and snippets.

@craigderington
Last active June 25, 2018 16:46
Show Gist options
  • Save craigderington/0d03e6b2140479ad3bcb71e0748e5b96 to your computer and use it in GitHub Desktop.
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.
# *-* 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