Created
February 9, 2013 04:14
-
-
Save socksy/4743803 to your computer and use it in GitHub Desktop.
Finding out the duplicate colour names
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
>>>> import csv | |
>>>> f = open("colors.txt") | |
>>>> ramalan = csv.reader(f, delimiter=',') | |
>>>> colours = [] | |
>>>> for x in ramalan: | |
... colours.append(x) | |
... | |
# Here we get rid of some malformed entries | |
>>>> colours = [c for c in colours if len(c) == 2] | |
# Now we look for duplicates by keeping track of what's been seen | |
>>>> seen = [] | |
>>>> for c in colours: | |
... for s in seen: | |
... if c[0]==s[0] and c[1]!=s[1]: # hex same, name different | |
... print c[1] + " with " + s[1] + " (" + c[0] + ")" | |
... if c not in seen: | |
... seen.append(c) | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment