ValueError: list.remove(x): x not in list (python 3.2)


I keep getting this error when running my code:

ValueError: list.remove(x): x not in list

With this code I’m supposed to check the elements in lst and in listOfOperatorsDomains. If they are the same (I used [if x in y] and not [if x == y] because of the context), then I append those two values to another list (listOfRequestsAssigned) and remove the element y from lst. However, the line where I remove the element y is giving me that error.
My code:

for y in lst: 
    for k in listOfOperatorsDomains:
        if y[2] in k:
            element = listOfOperatorsDomains.index(k)
return listOfRequestsAssigned


please have a read here for MCVE. we need at least a minimal sample list to work with (which we could simply copy paste and get right to your problem), that’s for not wasting everyone’s time, including yours as well. thanks a lot!



Add a Comment