Skip to content

Instantly share code, notes, and snippets.

@domodomodomo
Created July 24, 2018 03:52
Show Gist options
  • Save domodomodomo/56ff9b1ba6e9cea5d1eb1d0542627ee9 to your computer and use it in GitHub Desktop.
Save domodomodomo/56ff9b1ba6e9cea5d1eb1d0542627ee9 to your computer and use it in GitHub Desktop.
"""Compare two list."""
def equal_list(lst1, lst2):
lst1 = lst1.copy()
for element in lst2:
try:
lst1.remove(element)
except ValueError:
return False
if lst1:
return False
return True
def subtract_list(lst1, lst2):
lst = lst1.copy()
for element in lst2:
try:
lst.remove(element)
except ValueError:
continue
return lst
def intersect_list(lst1, lst2):
lst = []
lst1 = lst1.copy()
for element in lst2:
try:
lst1.remove(element)
except ValueError:
continue
else:
lst.append(element)
return lst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment