0

I have a list of lists into map object, if I do:

print(my_list)  # map object
print(list(my_list)) # [[1, 2], [1, 2, 3], [1]]

and I want to insert them into a set object to remove duplicate items.

I know I can do a for, or whatever, but I want to do in one line

I tried:

res = my_set.update(x) for x in my_list

but I got:

SyntaxError: invalid syntax

Any idea?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

Is this what you want?

{item for sublist in list(my_list) for item in sublist}
palvarez
  • 1,508
  • 2
  • 8
  • 18