Created
June 12, 2020 14:54
-
-
Save nitesh8860/f3aaffb2a723eb0e976d6acabcd01897 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fun(s): | |
# return True if s is a valid email, else return False | |
import re | |
rex = re.compile("^[\w\-\_]+\@[a-zA-Z0-9]+\.\w{1,3}$") | |
if rex.match(s): | |
return True | |
else: | |
return False | |
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) | |
#Sample Input | |
#2 | |
#harsh@gmail | |
#[email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment