Bootstrap FreeKB - Python (Scripting) - Remove duplicate values from a list
Python (Scripting) - Remove duplicate values from a list

Updated:   |  Python (Scripting) articles

Let's say you have an list that has duplicate values.

fruits = ["apple", "banana", "apple", "grapes"]

 

The list and set operators can be used to remove duplicate values from the list.

fruits = list(set(fruits))

 

Printing the fruits list  should now produce the following, where the list only contains apple once.

[u'apple', u'banana', u'grapes']

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter a86447 in the box below so that we can be sure you are a human.