Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Week05/emails_kerimcan_dede.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class Emails(list):

def validate(self):
for email in self:
if not isinstance(email, str):
raise ValueError("Emails must be string.")
if email.count("@") != 1:
raise ValueError("Emails must contain one @.")
if "." not in email.split("@")[1]:
raise ValueError("Emails must contain a dot after @.")
else:
print("Validation is successfull.")


def __init__(self, iterable=None):
super().__init__(iterable if iterable is not None else [])
try:
self.validate()
except ValueError as error:
print(error)

unique_emails = list(dict.fromkeys(self))
super().clear()
super().extend(unique_emails)

def __repr__(self):
return f"Email list : ({super().__repr__()})"

def __str__(self):
return f"Email list : {list(self)}"

@property
def data(self):
return self
Loading
⌂ Proxy