forked from sknsht/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.py
More file actions
30 lines (24 loc) · 652 Bytes
/
Copy pathSolution.py
File metadata and controls
30 lines (24 loc) · 652 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def fun(email):
try:
username, url = email.split('@')
website, extension = url.split('.')
except ValueError:
return False
if username.replace('-', '').replace('_', '').isalnum() is False:
return False
elif website.isalnum() is False:
return False
elif len(extension) > 3:
return False
else:
return True
def filter_mail(emails):
return list(filter(fun, emails))
if __name__ == '__main__':
n = int(input())
emails = []
for _ in range(n):
emails.append(input())
filtered_emails = filter_mail(emails)
filtered_emails.sort()
print(filtered_emails)