I have a code that essentially deletes any item in a list that is present in another list which contains more items that the list which deletes. The list which deletes contains image name of images i want to delete from the image upload input by user
This is the first code:
for i in images:
if i.name in adi:
# del images[images.index(i)]
images.pop(images.index(i))
This works for small file inputs but whenever i try to upload up to 21 or 20 image inputs then it errors in the amount it deletes whilst not deleting some items to be deleted in the list. So i tried running the same code twice:
for i in images:
if i.name in adi:
# del images[images.index(i)]
images.pop(images.index(i))
for k in images:
if k.name in adi:
images.pop(images.index(k))
Still with this, after accepting user input, there's still going to be at least one image remaining in the list that is meant to be deleted. Is anything wrong with the logic i'm using for implementation and if something is, how should i implement it instead