-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathAddressValidator.py
More file actions
28 lines (23 loc) · 957 Bytes
/
AddressValidator.py
File metadata and controls
28 lines (23 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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 < 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 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.
Beginner: You colud Also check if the inputed email has upper case or lower case as a validator factor.
"""