0
How to remove common elements from two lists using while or for loop? Its showing list out of range
9 Respostas
0
Santhos raj
Now I understood what you want.
Do you want this:
https://code.sololearn.com/cwzVH6FLZPw3/?ref=app
+ 1
A͢J - S͟o͟l͟o͟ H͟e͟l͟p͟e͟r͟ they didn't teach set in my school. So I can't use set
+ 1
A͢J - S͟o͟l͟o͟ H͟e͟l͟p͟e͟r͟ thank u so much
0
Simple way add both list in a set.
https://code.sololearn.com/cO4EstjRzLNP/?ref=app
0
Santhos raj
Ok but I have used for loop also. You can check shared code.
0
Santhos raj do you want to remove common elements from both lists?
0
Eashan Morajkar
You can try this
for i in list2:
if i not in list1:
list1.append(i)
print (list1)
0
Santhos raj Here's a possibility:
for x in list1:
if x in list2:
list1.remove(x)
list2.remove(x)
# Hope this helps
0
Calvin Thomas thanks a lot