Write is_email(s) that returns True if s looks like a simple email address under these rules:
- There is exactly one
@, separating a local part and a domain. - The local part is non-empty, contains only letters, digits,
.,_and-, and does not start or end with.. - The domain is made of labels separated by
.; there must be at least two labels, each label is non-empty and contains only letters, digits and-. - The last label (the top-level domain) consists of letters only and has length at least 2.
Examples
Input: s = "ada.lovelace@example.com"
Output: True
Input: s = "a@b"
Output: False
Explanation: the domain has only one label.
Input: s = ".dot@x.io"
Output: False
Explanation: the local part starts with a dot.
Constraints
0 <= len(s) <= 200, printable ASCII only
Goals
- Split a string into parts at a known separator
- Validate each part against a set of allowed characters
- Combine several independent conditions into one boolean