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 66c1535Copy full SHA for 66c1535
Week05/emails_helin_harman.py
@@ -0,0 +1,32 @@
1
+import re
2
+
3
4
+class Emails(list):
5
+ def __init__(self, emails):
6
+ self.validate(emails)
7
8
9
+ unique_emails = list(set(emails))
10
11
+ super().__init__(unique_emails)
12
+ self.data = unique_emails
13
14
+ def validate(self, emails):
15
+ if not isinstance(emails, list):
16
+ raise ValueError
17
18
+ email_regex = re.compile(
19
+ r"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$"
20
+ )
21
22
+ for email in emails:
23
+ if not isinstance(email, str):
24
25
+ if not email_regex.match(email):
26
27
28
+ def __repr__(self):
29
+ return f"Emails({list(self)})"
30
31
+ def __str__(self):
32
+ return "\n".join(self)
0 commit comments