Last active
July 18, 2018 03:33
-
-
Save BlogBlocks/15cc862c8a1953d67723cc6903a7532e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| """ | |
| This Hashes the list items and compares it to the a Hash of the proposed entry | |
| if entry exists it prints. list and "is already in" and the entry so you may see. | |
| if it enters it the new list is printed | |
| import NoListDups | |
| entrY = "XXiX" | |
| x = ['XXX', 'yyy', 'zzz'] | |
| NoListDups.NoDupList(x, entrY) | |
| print x | |
| """ | |
| import hashlib | |
| def hashIt(mystring): | |
| # Assumes the default UTF-8 | |
| hash_object = hashlib.md5(mystring.encode()) | |
| return(hash_object.hexdigest()) | |
| def NoDupList(lisT, entrY): | |
| for item in lisT: | |
| if hashIt(item) == hashIt(entrY): | |
| print entrY," is already in ",lisT | |
| break | |
| else: | |
| lisT.extend([entrY]) | |
| break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment