-1

I'm remaking this post to be more clear about my problem

Jorge Gill
  • 55
  • 11

1 Answers1

1

You could use a list comprehension to create a new list. With the following code you're checking whether an element x from A is in B. Every time x is in B, it is not included in your new list C.

A = [1, 1, 1, 2, 3, 4, 4, 5, 5, 5, 5]
B = [1, 3, 4]

C = [x for x in A if x not in B]
print(C)

outputs:

[2, 5, 5, 5, 5]
trotta
  • 1,232
  • 1
  • 16
  • 23
  • This soution doesn't work for me. In reality, A has 545332 string elements and B has 23. When running C = [x for x in A if x not in B], C elements are the same as B, substraction didn't happen – Jorge Gill May 16 '19 at 10:18