Union of multiple sets in python

后端 未结 7 936
逝去的感伤
逝去的感伤 2020-12-29 02:59
[[1, \'34\', \'44\'], [1, \'40\', \'30\', \'41\'], [1, \'41\', \'40\', \'42\'], [1, \'42\', \'41\', \'43\'], [1, \'43\', \'42\', \'44\'], [1, \'44\', \'34\', \'43\']         


        
7条回答
  •  隐瞒了意图╮
    2020-12-29 03:29

    In [20]: s
    Out[20]: 
    [[1, '34', '44'],
     [1, '40', '30', '41'],
     [1, '41', '40', '42'],
     [1, '42', '41', '43'],
     [1, '43', '42', '44'],
     [1, '44', '34', '43']]
    In [31]: list({x for _list in s for x in _list})
    Out[31]: [1, '44', '30', '42', '43', '40', '41', '34']
    

    Update:

    Thanks for the comments

提交回复
热议问题