Skip to content

Commit 6c1b748

Browse files
authored
Used current hackerrank code stab
1 parent e4ecc25 commit 6c1b748

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

PythonFunctionals/ValidatingEmailAddressesWithaFilter.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,24 @@
44
Domain : Python
55
Author : Ahmedur Rahman Shovon
66
Created : 15 July 2016
7+
Updated : 08 February 2023
78
Problem : https://www.hackerrank.com/challenges/validate-list-of-email-address-with-filter/problem
89
"""
910

10-
# Enter your code here. Read input from STDIN. Print output to STDOUT
1111
import re
1212

13-
n = int(input())
14-
ar = []
15-
for _ in range(n):
16-
s = input()
17-
if t := re.search(r"^[a-zA-Z][\w-]*@[a-zA-Z0-9]+\.[a-zA-Z]{1,3}$", s):
18-
ar.append(s)
19-
ar.sort()
2013

21-
print(ar)
14+
def fun(s):
15+
return re.search(r"^[\w-]+@[a-zA-Z0-9]+\.[a-zA-Z]{1,3}$", s)
16+
def filter_mail(emails):
17+
return list(filter(fun, emails))
18+
19+
if __name__ == '__main__':
20+
n = int(input())
21+
emails = []
22+
for _ in range(n):
23+
emails.append(input())
24+
25+
filtered_emails = filter_mail(emails)
26+
filtered_emails.sort()
27+
print(filtered_emails)

0 commit comments

Comments
 (0)