Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions Address Validator/AddressValidator.py
Original file line number Diff line number Diff line change
@@ -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.
"""