Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
A valid email address meets the following criteria:
Given n pairs of names and email addresses as input, print each name and email address pair having a valid email address on a new line.
Hint : Try using Email.utils() to complete this challenge. For example, this code:
import email.utils
print email.utils.parseaddr('DOSHI <DOSHI@hackerrank.com>')
print email.utils.formataddr(('DOSHI', 'DOSHI@hackerrank.com'))
produces this output:
('DOSHI', 'DOSHI@hackerrank.com')
DOSHI <DOSHI@hackerrank.com>
The first line contains a single integer, n, denoting the number of email address.
Each line i of the n subsequent lines contains a name and an email address as two space-separated values following this format:
name <user@email.com>
Print the space-separated name and email address pairs containing valid email addresses only. Each pair must be printed on a new line in the following format:
name <user@email.com>
You must print each valid email address in the same order as it was received as input.
2
DEXTER <dexter@hotmail.com>
VIRUS <virus!@variable.:p>
DEXTER <dexter@hotmail.com>
dexter@hotmail.com is a valid email address, so we print the name and email address pair received as input on a new line.
virus!@variable.:p is not a valid email address because the username contains an exclamation point (!) and the extension contains a colon (:). As this email is not valid, we print nothing.
# Enter your code here. Read input from STDIN. Print output to STDOUT
import re
N = input()
for i in xrange(N):
s = raw_input()
a = re.search(r'<[a-zA-Z][\w\.-]*@[a-zA-Z]*\.[a-zA-Z]{1,3}>', s)
if bool(a):
print(s)
# Enter your code here. Read input from STDIN. Print output to STDOUT
import re
n = int(input())
for _ in range(n):
x, y = input().split(' ')
m = re.match(r'<[A-Za-z](\w|-|\.|_)+@[A-Za-z]+\.[A-Za-z]{1,3}>', y)
if m:
print(x,y)
import email.utils
import re
n = int(raw_input())
for i in range(n):
p = email.utils.parseaddr(raw_input())
if re.match(r'[a-z][\w.-]+@[a-z]+\.[a-z]{1,3}$', p[1], re.I):
print email.utils.formataddr(p)
# Enter your code here. Read input from STDIN. Print output to STDOUT
import re
import email.utils
n = int(input().strip())
temp =[]
a = re.compile(r'<[a-z0-9][\w._-]+@[a-z]+\.[a-z]{1,3}>', re.I)
for _ in range(n):
temp.append(input().strip())
for i, x in enumerate(temp):
v = a.search(x)
if v:
print(temp[i])
In our experience, we suggest you solve this VValidating and Parsing Email Addresses Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
Validating and Parsing Email Addresses is available on Hacker Rank for Free, if you are stuck anywhere between compilation, just visit Queslers to get all Hacker Rank Solution
I hope this Validating and Parsing Email Addresses Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Hacker Rank Problem & Solutions >>
Mini-Max Sum Hacker Rank Solution
String Validators Hacker Rank Solution
Text Alignment Hacker Rank solution