Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def ismorethan6(emailaddress): #defining name of function and parameter
- emailaddress1 = emailaddress.split("@")[0].replace(".","") #store email name (without dots) part in variable
- if len(emailaddress1) < 6: #if lenght of email name part is lesser than 6 characters
- return (False,len(emailaddress1)) # return tuple False and lenght of email name part
- return (True,len(emailaddress1)) # if first if condition failed return tuple with True and lenght of email name part from this function
- def nomdot(emailaddress): # Function name nomdot "NO Multi DOTs" and parameter emailaddress Pac Man eats dots nom nom
- flag=False # flag variable initiated with False
- for char in emailaddress: # for every character stored in variable named emailaddress
- if char.isalnum(): # check if character is alpha numeric
- flag=True # if yes flag equals to 1
- elif char == "@" or char == ".": #else if character is @ or .
- if flag == True: # and flag equals to 1
- flag = False # set flag to 0 (store in variable called flag number 0)
- elif flag == False: #else if flag equals to 0
- return False # outcome of function is negative
- if flag == True: # if flag equals to number 1
- return True # outcome of function is positiv
- # function named "only one @"
- # checks there's only one "at" sign
- # in whole email address string"
- def onlyoneat(emailaddress):
- if emailaddress.count("@") == 1:
- return True
- return False
- while(1): # this is while loop. while 1 run code inside while loop
- emailaddress = input("Enter email address for validation check: ") #get input from keyboard and store it in emailaddress string variable
- if not emailaddress: # if emailaddress variable is None or empty
- break; #break while loop. goes out of loop. in this case means it will stop running our code
- if ismorethan6(emailaddress)[0] and nomdot(emailaddress) and onlyoneat(emailaddress): # if email address has at least 6 characters and has no at sign and/or dot more than two times in a row (e.g. it won't accept @@ .@ .. @.) and has only one at sign in whole email address
- print("Valid",ismorethan6(emailaddress)) # then email address is valid
- else:
- print("Invalid :(",ismorethan6(emailaddress)) # else it's not
Advertisement
Add Comment
Please, Sign In to add comment