We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 71f5b39 commit bacffdfCopy full SHA for bacffdf
Week05/emails_dilara_agac.py
@@ -0,0 +1,23 @@
1
+import re
2
+
3
4
+class Emails(list):
5
+ def __init__(self, emails):
6
+ self.validate(emails)
7
+ super().__init__(list(dict.fromkeys(emails)))
8
+ self.data = self
9
10
+ def validate(self, emails):
11
+ if not all(isinstance(e, str) for e in emails):
12
+ raise ValueError("All items must be strings")
13
14
+ email_pattern = re.compile(r"^[^@]+@[^@]+\.[^@]+$")
15
+ for email in emails:
16
+ if not email_pattern.match(email):
17
+ raise ValueError("Invalid email address")
18
19
+ def __repr__(self):
20
+ return f"{self.__class__.__name__}({list(self)})"
21
22
+ def __str__(self):
23
+ return ", ".join(self)
0 commit comments