Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from exceptions import MustContainAtSymbolError, NameTooShortError, InvalidDomainError
- possible_domains = [".com", ".bg", ".org", ".net"]
- while True:
- data = input()
- if data == "End":
- break
- email = data
- email_prats = email.split("@")
- if len(email_prats) != 2:
- raise MustContainAtSymbolError("Email must contain @")
- name, second_part = email_prats
- if len(name) <= 4:
- raise NameTooShortError(- "Name must be more than 4 characters")
- domain = f".{second_part.split('.')[-1]}"
- if domain not in possible_domains:
- raise InvalidDomainError(f"Domain must be one of the following: {', '.join(possible_domains)}")
- print("Email is valid")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement