I'm hvaing a hard time with a problem which I thought was pretty simple.
I have two lists:
- A small one, that looks like this:
list1 = ['A', 'B', 'C', 'D','E']
- The second list is much bigger, going on for about 800 elements. It looks like this:
list2 = ['E', 'B', 'F', 'A', 'C', 'N'...]
I want to scan list2 and see if all of its elements are the same as the ones in list1. If they are different, I want to see which are the elements that differ and cancel them from list2. In this example, I want to print "F" and "N" from list2 and cancel them.
I tried:
found = False
lenght2 = len(list2)
i = 0
for j in list1:
for i in range(0, lenght2):
if i != j:
found = True
#I don't know how to cancel i
print(i)
i = i + 1
break
However, the whole thing does not work.
Is there anyone who could help me?
question from:
https://stackoverflow.com/questions/65846239/how-to-scan-a-big-list-to-find-if-all-elements-match-the-ones-of-a-second-small 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…