Friday, 29 May 2020

Remove Duplicates From a Python List




list_data = [1,1,2,2,2,3,4,5]

list_data = list(dict.fromkeys(list_data))
print(list_data)

list_data = ['a','a','b','c']
list_data = list(dict.fromkeys(list_data))
print(list_data)


Out Put

No comments:

Post a Comment