Email address validation

Write codeMedium22 min

Your task

Implement simplified email-address validation. An address is valid iff: it has exactly one '@'; both local and domain parts are non-empty; the local part is at most 64 chars and the whole address at most 254; the local part contains only letters, digits, and the characters .!#$%&'*+/=?^_`{|}~- and does not start/end with a dot or contain '..'; the domain has at least two dot-separated labels, each label is 1-63 chars of letters/digits/hyphen, not starting or ending with a hyphen; and the whole address is ASCII. Return True/False.

Examples

validate_email(addr: str) -> bool
Example 1
Inputvalidate_email("user@example.com")
OutputTrue