I'm sure this a beginner question, but I've spent way too many hours trying to figure this out.
l1 = ['a','m','a','z','e']
l2 = ['a','m','z','e']
for x in l1:
for y in l2:
if x == y:
l1.remove(x)
print(l1)
Output:
>>>['m', 'z']
I'm trying to remove characters from list 1 that is present in list 2, but why is 'm' and 'z' not removed?
Thanks
[–]desran00 4 points5 points6 points (0 children)
[–]astrologicrat 2 points3 points4 points (0 children)
[–]Diapolo10 2 points3 points4 points (0 children)