delete the duplicates in python
mylist = ["a", "b", "a", "c", "c"]
mylist = list(dict.fromkeys(mylist))
print(mylist)
delete the duplicates in python
mylist = ["a", "b", "a", "c", "c"]
mylist = list(dict.fromkeys(mylist))
print(mylist)
Python remove duplicate lines from a text file
import hashlib
def main():
input_file = "in.txt"
output_file = "out.txt"
completed_hash = set()
output_file = open(output_file, "w")
for line in open(input_file,"r"):
hashValue = hashlib.md5(line.strip().encode('utf-8')).hexdigest()
if hashValue not in completed_hash:
output_file.write(line)
completed_hash.add(hashValue)
output_file.close()
if __name__ == "__main__":
main()
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us