Program to Remove Duplicates From a Python List
Now we will create a function where we can send our lists, and get them back without duplicates.
In this Case :
dict.fromkeys(list) #Create a dictionary, using this List items as keys. list(dict.fromkeys(list))# converted it to a list.
Run
$ python removeDuplicate.py
Output
['python', 'java', 'javaScript', 'java', 'python'] ['python', 'java', 'javaScript']
Hope this helps you.
Happy coding ....
Comments
Leave a comment
You are not LoggedIn but you can comment as an anonymous user which requires manual approval. For better experience please Login.