diff --git a/Address Validator/AddressValidator.py b/Address Validator/AddressValidator.py index 0dc49be..cbf2f7b 100644 --- a/Address Validator/AddressValidator.py +++ b/Address Validator/AddressValidator.py @@ -1,16 +1,11 @@ -def addressVal(address): - dot = address.find(".") - at = address.find("@") - if (dot == -1): - print("Invalid") - elif (at == -1): - print("Invalid") - else: - print("Valid") +import re 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("A valid email address must be in the format example@example.com.") + x = input("Input your email address: ") - addressVal(x) + result = re.fullmatch(r'^\S+@\S+\.\S+', x) + + if result: + break \ No newline at end of file