mail = "ahmet@asd.sda" def is_alphabetical(x): alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] try: alphabet.index(x.lower()) a = True except: a = False return a def is_mailnumeric(x): alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x", "y","z","0","1","2","3","4","5","6","7","8","9",".","-","_"] try: alphabet.index(x.lower()) a = True except: a = False return a at_pos = 0 dot_pos = 0 def find_at_position(mail): global at_pos for p in mail: at_pos = at_pos + 1 if p == "@": return at_pos def find_dot_position(mail): global dot_pos for p in mail: dot_pos = dot_pos + 1 if p == ".": return dot_pos if not(isinstance(find_at_position(mail), int)): print ("No @ found or mail invalid ") if not(isinstance(find_dot_position(mail), int)): print ("No . found or mail invalid") m = -1 while m == -1: if not(is_alphabetical(mail[0])): print("First letter problem mail invalid") exit() m = m + 1 ap = find_at_position(mail) dp = find_dot_position(mail) while m < (ap-1): m = m + 1 if not(is_mailnumeric(mail[m])): print("Invalid Email") exit() m = m + 1 while m > (ap-1) and m < (dp-1): m = m + 1 if is_alphabetical(mail[m])== False: print("Invalid email problem with domain") exit() while m > (dp-1) and m <= len(mail): n = 0 n = n + 1 if n > 3 or not(is_alphabetical(mail[m])): print ("Invalid email problem with extension") exit() print ("Valid email")