How to Remove Duplicates From a Python List

Configurare noua (How To)

Situatie

This is how you can remove duplicates from a List in Python.

Solutie

Pasi de urmat

mylist = [“a”, “b”, “a”, “c”, “c”]
mylist = list(dict.fromkeys(mylist))
print(mylist)

Output:

[‘a’, ‘b’, ‘c’]

Tip solutie

Permanent

Voteaza

(6 din 15 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?