Oct-26-2022, 04:03 PM
(This post was last modified: Oct-26-2022, 04:03 PM by deanhystad.)
Don't remove, append. I would build a new list that only contains the requirements you want to keep, and I would use set operations to determine which requirements to save
from collections import namedtuple from random import randint Import = namedtuple("Import", ("module", "name", "alias")) files = set(range(100, 200)) # All the requirements requirements = [Import(randint(1, 1000), randint(1, 1000), randint(1, 1000)) for _ in range(10)] # Requirements that have no match with any file. requirements = [req for req in requirements if set(req).isdisjoint(files)] print(*requirements, sep="\n")