Skip to content

Commit 166f0b7

Browse files
authored
Create emails_mert_can_fidan.py
## My Changes I created `Emails` class which satisfies `test_emails.py`. ## Checklist - [x] I have read [CONTRIBUTING]. - [x] I have performed a self-review of my own code. - [x] I have run the code locally and it works as explained. - [x] I have commented my code, particularly in hard-to-understand areas
1 parent a35cc10 commit 166f0b7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Week05/emails_mert_can_fidan.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Emails(list):
2+
def __init__(self, data: [str]) -> None:
3+
self.data = list(set(data))
4+
self.validate(data)
5+
6+
def __repr__(self):
7+
return f"Emails({self.data})"
8+
9+
def __str__(self):
10+
return f"Emails: {self.data}"
11+
12+
def validate(self, data: [str]) -> None:
13+
for email in data:
14+
if isinstance(email, int):
15+
raise ValueError("Only string values accepted!")
16+
if "@" not in email:
17+
raise ValueError("This is not an email adress!")

0 commit comments

Comments
 (0)