📜  使用 set 方法将两个列表相交 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:45.481000             🧑  作者: Mango

代码示例1
# Python program to illustrate the intersection
# of two lists using set() method
def intersection(lst1, lst2):
    return list(set(lst1) & set(lst2))
 
# Driver Code
lst1 = [15, 9, 10, 56, 23, 78, 5, 4, 9]
lst2 = [9, 4, 5, 36, 47, 26, 10, 45, 87]
print(intersection(lst1, lst2))