A simple Python program that splits an email address into its username and domain parts.
- Python 3
input()andprint()- String methods such as
find() - String slicing
- Basic conditional statements
- 📧 Accepts an email address from the user
- 🔍 Checks whether the email contains
@ - ✂️ Extracts the username part before
@ - 🌐 Extracts the domain part after
@ ⚠️ Shows an error message for invalid email input
- Make sure Python 3 is installed on your computer.
- Save the script as
Email separation.py. - Open a terminal or command prompt in the same folder.
- Run the program with:
python "Email separation.py"Then enter an email address when prompted.
If the email contains @, the program prints the username and domain separately.
If not, it prints an error message.
email: user@example.comUsername:user
Domain:example.comemail: userexample.comYour email is incorrect.⚠️ This script only checks for the presence of@, so it does not fully validate email format.- 💡 It is useful for learning string handling and basic validation in Python.