In this example we will show 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']
In this example we will show how to remove duplicates from a list in Python.
my_list = ['A', 'B', 'C', 'A', 'B', 'C']
my_list_new = list(dict.fromkeys(my_list))
print(my_list_new)
Output:
['A', 'B', 'C']
In this example we will show how to use functions to remove duplicates from a list in Python.
def my_function(x):
return list(dict.fromkeys(x))
my_list = ['A', 'B', 'C', 'A', 'B', 'C']
my_list_new = my_function(my_list)
print(my_list_new)
Output:
['A', 'B', 'C']