From 76bcac86412fdb2cdf19dcd102b167b00fdf0d60 Mon Sep 17 00:00:00 2001 From: rozdaman <159765883+rozdaman@users.noreply.github.com> Date: Mon, 22 Dec 2025 20:11:13 +0300 Subject: [PATCH] Create emails_roca_ozdaman.py --- Week05/emails_roca_ozdaman.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Week05/emails_roca_ozdaman.py diff --git a/Week05/emails_roca_ozdaman.py b/Week05/emails_roca_ozdaman.py new file mode 100644 index 00000000..981a77b4 --- /dev/null +++ b/Week05/emails_roca_ozdaman.py @@ -0,0 +1,23 @@ +import re + +class Emails(list): + def __init__(self, emails): + self.validate(emails) + self.data = list(set(emails)) + super().__init__(self.data) + + def validate(self, emails): + if not all(isinstance(e, str) for e in emails): + raise ValueError("All items must be strings") + + pattern = r"^[^@]+@[^@]+\.[^@]+$" + + for email in emails: + if not re.match(pattern, email): + raise ValueError("Invalid email address") + + def __repr__(self): + return f"{self.__class__.__name__}({self.data})" + + def __str__(self): + return ", ".join(self.data)