Validate email format

Write codeEasy12 min

Your task

Implement safe structural email validation for a registration form. Return True only if email is a single local part, exactly one '@', and a domain with a dot-separated TLD of at least two letters. Specifically it must match: local part of [A-Za-z0-9._%+-]+, then '@', then a domain of [A-Za-z0-9.-]+, then a literal dot, then a TLD of 2+ letters, anchored to the whole string. Reject anything with zero or multiple '@'. Empty string is invalid.

Examples

is_valid_email(email: str) -> bool
Example 1
Inputis_valid_email("alice@example.com")
OutputTrue