I’m new in python.
I just have a simple question:
I have two Lists of int (the lists have different number of elements).
I have to check if the elements of List2 exist in List1.
If the elements already exist, I want to remove them from List1.
I made this code:
list1 = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
list2 = [9,17]
for i in range(len(list1)):
for j in range(len(list2)):
if list2[j] == list1[i]:
but I received an error massage:
IndexError: list index out of range
→ if list2[j] == list1[i]:
Could you please help me to solve this issue?