Preparing git repo for final project
This commit is contained in:
23
problems/pset7/response/response.py
Normal file
23
problems/pset7/response/response.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from validator_collection import validators
|
||||
|
||||
|
||||
def main():
|
||||
if validate_email(input("What's your email address?\t\t")):
|
||||
print("Valid")
|
||||
else:
|
||||
print("Invalid")
|
||||
|
||||
|
||||
def validate_email(email: str) -> bool:
|
||||
try:
|
||||
email_address = validators.email(email, allow_empty = True)
|
||||
except Exception as e:
|
||||
email_address = None
|
||||
if not email_address:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
16
problems/pset7/response/test_response.py
Normal file
16
problems/pset7/response/test_response.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from response import validate_email
|
||||
|
||||
|
||||
def main():
|
||||
test_cs50p()
|
||||
|
||||
|
||||
def test_cs50p():
|
||||
assert validate_email("malan@harvard.edu")== True
|
||||
assert validate_email("info@cheznadi.com")== True
|
||||
assert validate_email("malan@@@harvard.edu")== False
|
||||
assert validate_email("info@cheznadi..com")== False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user