Skip to content

Instantly share code, notes, and snippets.

@vikychoi
Last active January 30, 2018 09:34
Show Gist options
  • Save vikychoi/43558f5e1cb01bd95a6646abd1deb066 to your computer and use it in GitHub Desktop.
Save vikychoi/43558f5e1cb01bd95a6646abd1deb066 to your computer and use it in GitHub Desktop.
List remove duplicates
def removeduplicates_v1(lst):
lst = set(lst)
return list(lst)
def removeduplicates_v2(lst):
new_lst = []
for i in range((len(lst)-1)):
if (lst[i] not in new_lst):
new_lst.append(lst[i])
return new_lst
eg = [1,2,3,4,1,2,3,4]
print("eg: ", eg, "\n")
print("v1: ", removeduplicates_v1(eg), "\n")
print("v2: ", removeduplicates_v2(eg), "\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment