array filter in python?

后端 未结 10 1115
一向
一向 2020-12-14 05:27

For example, I have two lists

 A           = [6, 7, 8, 9, 10, 11, 12]
subset_of_A  = [6, 9, 12]; # the subset of A


the result should be [7, 8, 10, 11]; t         


        
10条回答
  •  抹茶落季
    2020-12-14 05:39

    Use the Set type:

    A_set = Set([6,7,8,9,10,11,12])
    subset_of_A_set = Set([6,9,12])
    
    result = A_set - subset_of_A_set
    

提交回复
热议问题