How to take two lists and combine them excluding any duplicates?

后端 未结 5 633
無奈伤痛
無奈伤痛 2021-02-04 07:26

I\'d like to make one list from two separate lists of unique items.

There are other similar questions but there didn\'t seem to be any that concerned doing this problem

5条回答
  •  后悔当初
    2021-02-04 08:07

    >>> l1 = range(10)
    >>> l2 = range(5, 15)
    >>> set(l1) | set(l2)
    set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
    

提交回复
热议问题