I have a huge list of lists. I want to Merge all child lists to parent list and remove duplicates item from parent list after merge.
What is the optimized wa
first you can convert the list of list into a one list and than apply set to that list.
list
set
x = [['a', 'b', 'c', 2, 4], ['x', 1, 2, 3, 'z'], ['z', 'b', 'y', 'a' 'x']] new_ls=[] for ls in x: new_ls.extend(ls) print(list(set(new_ls))
output:
[1, 2, 3, 4, 'ax', 'b', 'y', 'x', 'c', 'z', 'a']