python – e-mail validation function

Good evening guys!

I need help with this code because I break my head and I can not solve it.

It looks like this: You first enter the number of emails you want to enter as input. Then you type the emails based on the number you typed before. Once this is done, the program will check if it passes the regular expression rule, it adds that it goes to a list, otherwise it does not add it and return the list in alphabetical order at the end.

The code is like this for the moment:

import re
def fun (s):
# return True if is a valid email, otherwise return False

s = emails
standard = (r & # 39;[w-]+ [a-zd]+ .[w](S)

for i in the range (len (s)):
if[i] = default:
returns True
if not:
returns False

def filter_mail (emails):
return list (filter (fun, emails))

if __name__ == __ hand __:
n = int (input ())
emails = []
for _ in the range (n):
emails.append (input ())

filter_emails = filter_mail (emails)
filtered_emails.sort ()
print (filtered_emails)