Created
May 10, 2018 12:20
-
-
Save mhighmore/7e350ef9ad5ad46c9438515be786c308 to your computer and use it in GitHub Desktop.
EmailValidationProgv3.py
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
## validate an email address | |
def main(): | |
emailaddress = getmyEmail() | |
print(emailaddress) | |
print (len(emailaddress)) | |
if checkatsigninemail(emailaddress) == True and validationwithdot(emailaddress) == True: | |
print("meets all the parameters for email") | |
else: | |
print("this is invalid") | |
def checkdotafterat(x): | |
x.index("@") | |
def getmyEmail(): | |
email = "" | |
while len(email) <1: | |
email =input("Pls enter an email >> ") | |
if len(email)>=1: | |
return email | |
else: | |
print("pls enter something") | |
def checkatsigninemail(email): | |
if "@" in email and email.count("@") == 1 and email.index("@") > 0: | |
email.split("@") | |
atpos = email.index("@") | |
endofemail = len(email) | |
emailafteratsign = email[atpos:endofemail] | |
if len(emailafteratsign) > 0 and "." in emailafteratsign and emailafteratsign.count("@") ==1: | |
atposdot = emailafteratsign.index(".") | |
emailafteratandsign = emailafteratsign[atposdot:len(emailafteratsign)] | |
if atposdot >1 and emailafteratandsign[0:len(emailafteratandsign)].isalpha: | |
return True | |
else: | |
print("must be a character after the @ sign followed by some text then a dot") | |
elif len(emailafteratsign) < 0: | |
print("must have something after the @ sign to be valid") | |
elif not "." in emailafteratsign: | |
print("has to have a '.' somewhere after the @ sign") | |
else: | |
if not "@" in email: | |
print("must have an @ sign") | |
elif email.count("@") > 1: | |
print("too many @'s") | |
elif email.index("@") == 0: | |
print("can not have an @ for openers") | |
return False | |
def validationwithdot(email): | |
if email.count(".") >= 1: | |
return True | |
else: | |
print("must have a dot '.' in there somewhere") | |
return False | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment