Ok so i need to make a program that you put in an email address and it checks for the @ symbol and then makes sure its not the first digit or the last digit. Now i know that there is " like s.islower( for lowercase) and s.isupper but i dont know if theres a s.is "@"

can someone help me?

def main():

    print "This program validates a email address"
    email = raw_input("Enter Your email: ")
    
   if isValid(email):
        print ("That is a valid email")
       
    else:
        print ("That email is not valid.")
       
    raw_input("\nPress <enter> to close window.")


def isValid(s):
    
    
    if s.is"@"() == 0:
        print "There is no @ symbol"
        return False
    if s.isfirst(@) == 0:
        print "the @ cannot be first"
        return False
    if s.islast(@) == 0:
        print "the @ cannot be last"
        return False
    
    return True

main()

Ok i got the endswith and the startswith. but im not sure how to check for the @ symbol. so what method checks for a symbol?

To check for a valid email adress regular expression is a god tool.

import re

mail_input = raw_input("Enter your email: ")

if re.match(r"\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b\Z", mail_input, re.IGNORECASE):
    print ("That is a valid email")
else:
    print ("That email is not valid")

Or keep it simple:

if "@" not in mail_input:
    print "There is no '@' symbol!"

Ok i got the endswith and the startswith. but im not sure how to check for the @ symbol. so what method checks for a symbol?

You are on the right track ...

def isValid(s):
    if "@" not in s:
        print "There is no @ symbol"
        return False
    if s.startswith("@"):
        print "the @ cannot be first"
        return False
    if s.endswith("@"):
        print "the @ cannot be last"
        return False
    return True

# testing ...
isValid("Cyproz@hotshot.com")
isValid("Cyprozathotshot.com")
isValid("@Cyprozathotshot.com")
isValid("Cyprozathotshot.com@")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.