We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
if u[0].isalpha() and "@" not in u:
out=n+"<"+u+"@"
if d.isalpha():
out+=d
if len(e)<=4 and len(e)>0:
if e.isalpha():
out+="."+e+">"
print(out)
for i in range(n):
a.append(input())
for email in a:
if "<" in email:
name,mail=email.split("<",1)
if "@" in mail:
user, domain_with_ext = mail.split("@", 1)
if "." in domain_with_ext:
domain, exten = domain_with_ext.split(".", 1)
if ">" in exten:
ext,new_str=exten.split(">",1)
validity(name,user,domain,ext)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Validating and Parsing Email Addresses
You are viewing a single comment's thread. Return to all comments →
import email.utils name="" user="" domain="" ext="" a=[] out="" new_str=""
n=int(input())
def validity(n,u,d,e):
for i in range(n): a.append(input())
for email in a: if "<" in email: name,mail=email.split("<",1) if "@" in mail: user, domain_with_ext = mail.split("@", 1)