From fdbf3cbad8e6ee5b45b2582137e2a9f86bc3b52d Mon Sep 17 00:00:00 2001 From: Abukolucky <128996269+Abukolucky@users.noreply.github.com> Date: Fri, 5 Dec 2025 18:04:57 +0300 Subject: [PATCH] A Barebone Basic Beginner Email Validator Using a function, it checks whether the email address passed to it is valid or not. Note: This is only a beginner-focused program aimed at someone who has just started learning or has just finished learning about functions --- Address Validator/AddressValidator.py | 36 ++++++++++++++++++--------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/Address Validator/AddressValidator.py b/Address Validator/AddressValidator.py index 0dc49be1..5a8a4e85 100644 --- a/Address Validator/AddressValidator.py +++ b/Address Validator/AddressValidator.py @@ -1,16 +1,28 @@ -def addressVal(address): +def addressVal(address:str)-> str: + """ + Takes an Email address string returning a valid or inavlid string output. + + Args: + address: Email Address string + """ dot = address.find(".") at = address.find("@") - if (dot == -1): - print("Invalid") - elif (at == -1): - print("Invalid") - else: - print("Valid") + if (dot < 0) and (at != 1): # An email address can have more than one (.) but only one (@) + return f"Invalid Email Address: {address}" + return f"Valid Email Address: {address}" + -print("This program will decide if your input is a valid email address") -while(True): - print("A valid email address needs an '@' symbol and a '.'") - x = input("Input your email address:") +print("This program checks whether an Email Address is valid.") +while True: + + email = str(input("Please Enter An Email Address or (q) to quit: ")).strip() + if email.lower() == "q": + print("Exiting...") + break + addressVal(email) +""" +NOTE: This a beginner -- beginner email validator A more robust/ complex validator would use tools like +regex(re) to fine tune the validation process further. - addressVal(x) +Beginner: You colud Also check if the inputed email has upper case or lower case as a validator factor. +"""