How to Remove Duplicates From a List in Python


In this example, we will learn how to remove duplicates from a list in Python.

Source Code

my_list = ['A', 'B', 'C', 'A', 'B', 'C']
my_list_new = list(dict.fromkeys(my_list))
print(my_list_new)

Output:

['A', 'B', 'C']
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments