You are viewing a single comment's thread. Return to all comments →
Solution without any module e.g Regex
def fun(s): delimitor= ['@', '.'] for i in delimitor: s= s.replace(i, " ") s= s.split(" ") if len(s) == 3 and all([i != '' for i in s]): if (all(c.isalnum() or c in ('-', '_') for c in s[0]) and s[1].isalnum() and s[2].isalpha() and len(s[2]) <= 3): return True else: return False def filter_mail(emails): return list(filter(fun, emails)) if __name__ == '__main__': n = int(input()) emails = [] for _ in range(n): emails.append(input()) filtered_emails = filter_mail(emails) filtered_emails.sort() print(filtered_emails)
Seems like cookies are disabled on this browser, please enable them to open this website
Validating Email Addresses With a Filter
You are viewing a single comment's thread. Return to all comments →
Solution without any module e.g Regex