Skip to content

Commit da238fb

Browse files
Create [email protected]_muhammet_gulden.py
1 parent 71f5b39 commit da238fb

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# emails_isim_soyisim.py
2+
import re
3+
4+
class Emails(list):
5+
def __init__(self, email_list):
6+
self.validate(email_list)
7+
8+
unique_emails = []
9+
for email in email_list:
10+
if email not in unique_emails:
11+
unique_emails.append(email)
12+
13+
self.data = unique_emails
14+
15+
super().__init__(unique_emails)
16+
17+
def validate(self, email_list):
18+
"""Email listesini validate eder"""
19+
for email in email_list:
20+
if not isinstance(email, str):
21+
raise ValueError(f"{email} is not a string")
22+
23+
if '@' not in email or '.' not in email:
24+
raise ValueError(f"{email} is not a valid email address")
25+
26+
if email.index('@') > email.rindex('.'):
27+
raise ValueError(f"{email} is not a valid email address")
28+
29+
def __repr__(self):
30+
"""repr() fonksiyonu için"""
31+
return f"Emails({self.data})"
32+
33+
def __str__(self):
34+
"""print() için"""
35+
return f"Emails({self.data})"

0 commit comments

Comments
 (0)