Skip to content

Instantly share code, notes, and snippets.

@sdfsdhgjkbmnmxc
Created August 23, 2018 13:29
Show Gist options
  • Save sdfsdhgjkbmnmxc/793dadc75b2f4ae2fbeffe5a49f287c8 to your computer and use it in GitHub Desktop.
Save sdfsdhgjkbmnmxc/793dadc75b2f4ae2fbeffe5a49f287c8 to your computer and use it in GitHub Desktop.
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