Validating Email Addresses With a Filter

  • + 0 comments

    whats the runtime error in these code

    def fun(s): # return True if s is a valid email, else return False if "@" in s: username, rest = s.split('@') if "." in rest: web_name, ext = rest.split('.') if username and web_name and ext.isalpha() and len(ext) <= 3 and web_name.isalnum() and all(ch.isalnum() or ch in '-_' for ch in username): return True return False def filter_mail(emails): return list(filter(fun, emails))

    if name == 'main': n = int(input()) emails = [] for email in range(n): emails.append(input())

    filtered_emails = filter_mail(emails) filtered_emails.sort() print(filtered_emails)