Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8130485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:43:41+00:00 2026-06-06T08:43:41+00:00

I am making algorithm for checking the string (e-mail) – like E-mail addres is

  • 0

I am making algorithm for checking the string (e-mail) – like “E-mail addres is valid” but their are rules. First part of e-mail has to be string that has 1-8 characters (can contain alphabet, numbers, underscore [ _ ]…all the parts that e-mail contains) and after @ the second part of e-mail has to have string that has 1-12 characters (also containing all legal expressions) and it has to end with top level domain .com

email = raw_input ("Enter the e-mail address:")
length = len (email)
if length > 20 
    print "Address is too long"
elif lenght < 7:
    print "Address is too short"  
if not email.endswith (".com"):   
    print "Address doesn't contain correct domain ending"   
try:
    first_part = len (splitting[0])
    second_part = len(splitting[1])  

    account = splitting[0]
    domain = splitting[1] 

    list = "abcdefghijklmopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_."

    for c in account: 
        if c not in list:
            print "Invalid char", "->", c,"<-", "in account name of e-mail"

    for c in domain:
        if c not in list:
            print "Invalid char", "->", c,"<-", "in domain name of  e-mail"

    if first_part == 0:
        print "You need at least 1 character before the @"
    elif first_part> 8:
        print "The first part is too long"
    if second_part == 4:
        print "You need at least 1 character after the @"
    elif second_part> 16:
        print "The second part is too long"
except IndexError:
        print ""The address must consist of 2 parts connected with symbol @,\
 and ending must be .com"

    if first_part > 0 and first_part < 8 and second_part >4 and second_part < 16:
       print "Valid e-mail address"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:43:43+00:00Added an answer on June 6, 2026 at 8:43 am

    If I understood well, you got everything working, except the part of finding invalid chars. Is that true?

    Do you know the for loop? It may be helpful to you. Just get the parts of the e-mail:

    account = splitting[0]
    domain = splitting[1]
    

    Then, iterate over each part. It will yield a character each time. If this char is not in the set of allowed ones, you print a message:

    for c in account:
        if c not in "abcdefghijklmopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.":
            print "Invalid char", c, "in e-mail"
    
    for c in domain:
        if c not in "abcdefghijklmopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.":
            print "Invalid char", c, "in e-mail"
    

    This is not a very elegant solution (one could use string.ascii_letters+string.digits+"._" instead of "abcdefghijklmopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.", for example, or list comprehesions), but I bet it is sufficiently understandable for a new user.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to store equivalences from Connected-component labeling algorithm . It's basically making
I'm an old C++ / algorithm guy who is making a first attempt at
I am making a program which implements the mergesort algorithm but instead of dividing
I'm making a enciphering/deciphering program using XTEA algorithm. The encipher/decipher functions work fine, but
I am making an algorithm builder and have a main text box on top,
I'm making a program on the HUFFMAN ALGORITHM where I have one class of
Making a new site but something is happening to it in IE8. The social
Making a new site but something is happening to it in IE. I've purchased
The Algorithm traverses a 2D NxN array, making every element the average of its
I am making a program using the LRV(Least recently visited) Algorithm. Basically, I design

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.