From 875e693316b2b34637da70e1f2b8d7c93fa4bc83 Mon Sep 17 00:00:00 2001 From: Ensar514 Date: Tue, 23 Dec 2025 13:17:06 +0300 Subject: [PATCH] Implement Emails class for unique email storage --- Week05/emails_ensar_bastopcu.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Week05/emails_ensar_bastopcu.py diff --git a/Week05/emails_ensar_bastopcu.py b/Week05/emails_ensar_bastopcu.py new file mode 100644 index 00000000..d3753a9f --- /dev/null +++ b/Week05/emails_ensar_bastopcu.py @@ -0,0 +1,22 @@ +class Emails(list): + def __init__(self, emails): + self.validate(emails) + unique_emails = [] + for email in emails: + if email not in unique_emails: + unique_emails.append(email) + super().__init__(unique_emails) + self.data = self + + def validate(self, emails): + for email in emails: + if not isinstance(email, str): + raise ValueError + if "@" not in email or "." not in email: + raise ValueError + + def __repr__(self): + return f"Emails({super().__repr__()})" + + def __str__(self): + return super().__str__()