HackerRank Validating and Parsing Email Addresses solution in Python YASH PAL, 31 July 202417 January 2026 HackerRank Validating and Parsing Email Addresses solution in Python – In this Validating and Parsing Email Addresses problem, you are 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.A valid email address meets the following criteria: It’s composed of a username, domain name, and extension assembled in this format: username@domain.extensionThe username starts with an English alphabetical character, and any subsequent characters consist of one or more of the following: alphanumeric characters, -,., and _.The domain and extension contain only English alphabetical characters.The extension is 1, 2, or 3 characters in length.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> HackerRank Validating and Parsing Email Addresses solution in Python 2.# 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)Validating and Parsing Email Addresses solution in Python 3.# 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)Problem solution in pypy programming.import email.utilsimport ren = 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} coding problems solutions Hackerrank Problems Solutions Python Solutions HackerRankPython