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