In this HackerRank Validating and Parsing Email Addresses problem solution 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.

HackerRank Validating and Parsing Email Addresses in python problem solution

HackerRank Validating and Parsing Email Addresses in python problem solution

import re
pat = r'^([a-z]+ \<[a-z][-.\w]*@[a-z]+\.[a-z]{1,3}\>)'
for _ in range(int(input())):
    match = re.match(pat, input(), re.I)
    if match:
        print(match.group(1))