This Python script is designed to validate an email address based on a set of specific criteria. The purpose of the script is to ensure that the email format conforms to standard rules while also adhering to additional customized validation requirements.
-
Length Check:
- The email must have a minimum length of 6 characters.
-
Starting Character:
- The first character of the email must be an alphabetic letter (a-z or A-Z).
-
"@" Symbol:
- The email must contain exactly one "@" symbol.
-
Domain Validation:
- The email should end with a valid domain, such as
.com
,.org
, or.net
. - The script ensures the last 3rd or 4th character from the end is a period (
.
).
- The email should end with a valid domain, such as
-
Character Restrictions:
- Allowed characters: letters (a-z), numbers (0-9), and special characters (
_
,.
,@
). - Disallowed characters include spaces, uppercase letters, and unsupported special characters.
- Allowed characters: letters (a-z), numbers (0-9), and special characters (
-
Error Handling:
- Each validation step is associated with a specific error message, helping users understand why their input failed the validation.
-
Input:
- The script prompts the user to enter an email address.
-
Validation:
- Sequential checks are performed in the following order:
- Length of the email.
- Validity of the first character.
- Presence and count of the "@" symbol.
- Proper domain structure (ending in
.xyz
,.abc
, etc.). - Character-by-character analysis to detect invalid spaces, uppercase letters, or unsupported symbols.
- Sequential checks are performed in the following order:
-
Output:
- If the email fails any validation step, a corresponding error message is displayed.
- If the email passes all checks, it is declared valid.
- "Wrong Email 1": Email is too short.
- "Wrong Email 2": First character is not a letter.
- "Wrong Email 3": Missing or multiple
@
symbols. - "Wrong Email 4": Domain format is invalid.
- "Wrong Email 5": Contains spaces, uppercase letters, or unsupported characters.
- Input:
[email protected]
- Output:
Email is valid
- Input:
[email protected]
- Output:
Wrong Email 5