I have two lists of A and B. When I found a value of B in A, I want to remove the value in A. But without "redo" in python, it makes a problem. There might be diverse codings for that but I want to know a very smart or simple or pythonic coding.
I need "redo" for this, but python does not have "redo".
A = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
B = ['Feb', 'Mar', 'Apr']
for mon in A:
if mon in B:
A.remove(mon)
print(A)
returns ['Jan', 'Mar', 'May', 'Jun']
After removing 'Feb' in A, due to the A.remove() method, 'Mar' is skipped.
I need to explain my case more because there are many kinds of solutions. Basically I want to keep A because A is a reference with long list elements. Then during a looping of many B's, I want to remove those elements in B from A. So I need to keep A until the end of program, removing elements which belongs to any B.