我想检查list1[0]
中是否包含list2[0]
值,然后再检查list1[1] -> list2[1]
...,以便得到与以下相同的结果:
list1 = [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
list2 = [[2, 5], [4, 6, 8], [4]]
result = [[False, True, False], [False, False, True], [False, True, False]]
答案 0 :(得分:0)
您可以使用嵌套列表推导:
result = [[x in b for x in a] for a, b in zip(list1, list2)]
print(result)
输出:
[[False, True, False], [False, False, True], [False, True, False]]