Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- # Filename: is_valid_email.py
- # Author: Jeoi Reqi
- """
- Valid Email Checker Script
- This script prompts the user to enter an email address and checks whether
- it is in a valid email format. It utilizes a function, valid_email, to
- perform the email validation.
- Requirements:
- - Python 3
- Usage:
- 1. Run the script.
- 2. Enter an email address when prompted.
- 3. The script will display whether the entered email address is valid or not.
- """
- import re
- def valid_email(email):
- """Check for a valid email address.
- Args:
- email (str): Email.
- Returns:
- bool: True if in valid email format, False otherwise.
- """
- return bool(re.match('^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$', email))
- def main():
- # Get user input for email address
- user_email = input("Enter an email address: ")
- # Check if the email is valid
- if valid_email(user_email):
- print("The entered email address is Valid.")
- else:
- print("The entered email address is Not Valid.")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement