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.
import re
pattern = r'^[a-zA-z][a-zA-Z0-9_.-]*@[a-z]+.[a-z]{1,3}$'
n = int(input())
for i in range(n):
i = input().strip()
m = re.match(r'(.+)<(.+)>',i)
if m:
name = m.group(1).strip()
email = m.group(2).strip()
if re.match(pattern,email):
print('{} <{}>'.format(name,email))
help me find the problem in my code because i have passed 6 out of 7 cases but this code is failing agaist test case 3 i don't know why even chat GPT could not help if anyone it would be quite appreciating and i will be obliged of him...
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 re pattern = r'^[a-zA-z][a-zA-Z0-9_.-]*@[a-z]+.[a-z]{1,3}$'
n = int(input()) for i in range(n): i = input().strip() m = re.match(r'(.+)<(.+)>',i) if m: name = m.group(1).strip() email = m.group(2).strip() if re.match(pattern,email): print('{} <{}>'.format(name,email))
help me find the problem in my code because i have passed 6 out of 7 cases but this code is failing agaist test case 3 i don't know why even chat GPT could not help if anyone it would be quite appreciating and i will be obliged of him...