Python (Scripting) - Remove duplicate values from a list

by
Jeremy Canfield |
Updated: November 06 2023
| 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