Hello I created two lists as the following:
listA = ['A', 'B','C','D','1','2','3', 'A', 'D','2']
listB = ['A', 'B','C','D']
I want to remove all listB
elements that are in listA
. I did this:
array_length = len(listB)
for i in range(array_length):
listA.remove(listB[i])
but it only removed only each element if there is duplicated ones. the output was
['1', '2', '3', 'A', 'D', '2']
my desired output is:
['1', '2', '3', '2]