# Validating And Parsing Email Addresses Hackerrank Solution In Python

Last updated March 7, 2024 by Jarvis Silva

In this article, I will share the validating and parsing email addresses hackerrank solution in python. Hackerrank is a popular online platform which has many programming challenges and competitions which allows developers to participate into them and improve their programming skill.

## Question

In this challenge we will be given Given N pairs of names and email addresses as input, we have to print each name and email address pair having a valid email address on a new line.

You can find the full question of this problem here: Validating And Parsing Email Addresses Hackerrank Challenge Question.

In this challenge we have to use the re module and the email.utils module we have to create python program to validate and print email address along with name.

Before moving to the solution you should definately try to do this on your own it is very easy but still if you can’t solve it don’t worry you can check the below solution and understand this program.

## Solution

``````
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])
```
```

Above is the python solution for the validating and parsing email addresses Hackerrank challenge, you can submit the above code in hackerrank and it should show you congratulations you solved this challenge.

So this was for this article, I hope you found what you were looking and if you want more hackerrank solutions then visit here: Hackerrank python solutions.

Thank you for reading, Happy coding 😊