Python - alternative to list.remove(x)?
        Posted  
        
            by Seafoid
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Seafoid
        
        
        
        Published on 2010-06-02T13:20:27Z
        Indexed on 
            2010/06/02
            13:34 UTC
        
        
        Read the original article
        Hit count: 222
        
Hi,
I wish to compare two lists. Generally this is not a problem as I usually use a nested for loop and append the intersection to a new list. In this case, I need to delete the intersection of A and B from A.
 A = [['ab', 'cd', 'ef', '0', '567'], ['ghy5'], ['pop', 'eye']]
 B = [['ab'], ['hi'], ['op'], ['ej']]
My objective is to compare A and B and delete A intersection B from A, i.e., delete A[0][0] in this case.
I tried:
def match():
    for i in A:
        for j in i:
            for k in B:
                for v in k:
                    if j == v:
                        A.remove(j)
list.remove(x) throws a ValueError.
© Stack Overflow or respective owner