Skip to content

Commit 0e67d7f

Browse files
solves validating email address with filter
1 parent 9c0e063 commit 0e67d7f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import re
2+
3+
pattern = '([a-z]|[A-Z]|\d|_|-)+@([a-z]|[A-Z]|\d)*[.].{1,3}'
4+
5+
6+
def fun(email):
7+
match = re.fullmatch(pattern, email)
8+
if match is not None:
9+
return match.span() == (0, len(email))
10+
11+
12+
def filter_mail(emails):
13+
return list(filter(fun, emails))
14+
15+
16+
if __name__ == '__main__':
17+
n = int(input())
18+
emails = []
19+
for _ in range(n):
20+
emails.append(input())
21+
22+
filtered_emails = filter_mail(emails)
23+
filtered_emails.sort()
24+
print(filtered_emails)

0 commit comments

Comments
 (0)