-
-
Save sdfsdhgjkbmnmxc/793dadc75b2f4ae2fbeffe5a49f287c8 to your computer and use it in GitHub Desktop.
This file contains 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 get_emails(): | |
emails = {} | |
with open('list.txt', 'r') as f: | |
lines = f.readlines() | |
for l in lines: | |
l = l.strip() | |
if '@' in l: | |
a, d = l.split('@') | |
if d: | |
if d in emails: | |
emails[d].append(a) | |
else: | |
emails[d] = [a] | |
return emails | |
# ====> | |
def get_emails(): | |
emails = {} | |
with open('list.txt', 'r') as f: | |
for line in f: | |
line = line.strip() | |
if '@' not in line: | |
continue | |
user, domain = l.split('@') | |
if domain: | |
emails.setdefault(domain, []).append(user) | |
return emails |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment