Last active
August 29, 2015 14:01
-
-
Save ungarst/153edccc8f61d7e161fc to your computer and use it in GitHub Desktop.
Case Insensitive Unique List
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
def unique_list(list): | |
u_list = [] | |
[u_list.append(x) for x in list if x.lower() not in [y.lower() for y in u_list]] | |
return u_list | |
print (unique_list(["Welcome", "to", "COMPSCI101", "to", "wELcome"])) | |
# BETTER VERSION!!! | |
def unique_list(list): | |
return [list[i] for i in range(0,len(list)) if list[i].lower() not in [y.lower() for y in list[:i]]] | |
print (unique_list(["Welcome", "to", "COMPSCI101", "to", "wELcome"])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment