def canonicalize_emails(changelog, mapping):
 for (alias, email_address) in mapping.iteritems():
  changelog = changelog.replace(alias, email_address)
 return changelog

def canonicalize_emails ( changelog , mapping ) : for ( alias , email_address ) in mapping . iteritems ( ) : changelog = changelog . replace ( alias , email_address ) return changelog
takes in a string and an email alias mapping and replaces all instances of the aliases in the string with their real email .