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 way to do this?
For Example:
x = [['a', 'b', 'c', 2, 4], ['x', 1, 2, 3, 'z'], ['z', 'b', 'y', 'a' 'x']]
How we can get the value of x like:
['a', 'b', 'c', 1, 2, 3, 4, 'z', 'y', 'x']
Use
set
first you can convert the
list
oflist
into a onelist
and than applyset
to thatlist
.output:
Use set and chain: