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