Created
July 24, 2018 03:52
-
-
Save domodomodomo/56ff9b1ba6e9cea5d1eb1d0542627ee9 to your computer and use it in GitHub Desktop.
This file contains 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
"""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