I have this class
class Accounts:
def __init__(self, id, name, date):
self.id = id
self.name = name
self.date = date
and two lists of this classes
accounts = []
expired_accounts = []
I want to delete elements which are in expired_accounts
from accounts
(expired_accounts - accounts)
Appending elements
accounts.append(Accounts(id=690000, name="test", date=123456))
print(len(accounts))
expired_accounts(Accounts(id=690000, name="test", date=123456))
print(len(expired_accounts))
Output:
1
1
Now trying to remove elements
test = [x for x in accounts if x not in set(expired_accounts)]
print(len(test))
Output (expecting 0):
1
I tried different solutions from this thread, but neither of them work for my case and I don't know why. Could someone help me, where is the problem?