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