regex - Python function that corrects a email domain -
okay, have function construct_email(name, domain):
def construct_email(name, domain): if domain == true: print 'true' else: print'none' return name + "@" + domain
this function isn't big or anything, it's suppose output email address. have other function correct_domain(domain):
suppose check domain name that's been input in construct_email(name, domain):
import re def correct_domain(domain): if re.search(r'^\.|\.$', domain) or re.search(r'\.\.', domain): return false elif re.search(r'\.', domain): return true else: return false
my question is, how do this?
if i'm understanding correctly:
import re def construct_email(name, domain): if not check_domain(domain): return false return name + "@" + domain def check_domain(domain): dots = re.findall(r"\.", domain) if (len(dots) != 1) or domain.startswith(".") or domain.endswith("."): return false return true def main(): while true: email = construct_email(raw_input("name: "), raw_input("domain: ")) if email: break print "bad domain, try again...\n" print email #other code here...
Comments
Post a Comment