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

后端 未结 5 634
無奈伤痛
無奈伤痛 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 07:44

    Clean and professional solution:

    list = [1, 2, 3]
    list1 = [3, 4, 5]
    result = list(set().union(list, list1)) # result [1, 2, 3, 4, 5]
    

提交回复
热议问题