Python please. so this code is in the split method, how would I re write in the find/in/endswith method. def isEmailValid(mail): boolean = 0 x = mail.split("@")[0].count(".") if "@" not in mail or x>1: boolean =1 elif "." not in mail.split("@")[0]: boolean = 1 elif not mail.endswith("bellevuecollege.edu"): boolean=1 elif mail.split("@")[0].split(".")[0] =="" or mail.split("@")[0].split(".")[1] =="": boolean=1 if boolean==0: return True else: return False def main(): while True: email = input("Enter the email address: ") if isEmailValid(email): print("Valid Email") choice = input("Want to continue (y/n) ? ") if choice == "n": break else: print("Invalid Email") choice = input("Want to continue (y/n) ? ") if choice == "n": break if __name__ == "__main__": main()
Python please. so this code is in the split method, how would I re write in the find/in/endswith method.
def isEmailValid(mail):
boolean = 0
x = mail.split("@")[0].count(".")
if "@" not in mail or x>1:
boolean =1
elif "." not in mail.split("@")[0]:
boolean = 1
elif not mail.endswith("bellevuecollege.edu"):
boolean=1
elif mail.split("@")[0].split(".")[0] =="" or mail.split("@")[0].split(".")[1] =="":
boolean=1
if boolean==0:
return True
else:
return False
def main():
while True:
email = input("Enter the email address: ")
if isEmailValid(email):
print("Valid Email")
choice = input("Want to continue (y/n) ? ")
if choice == "n":
break
else:
print("Invalid Email")
choice = input("Want to continue (y/n) ? ")
if choice == "n":
break
if __name__ == "__main__":
main()
Step by step
Solved in 2 steps with 1 images