DEV Community

SILAMBARASAN A
SILAMBARASAN A

Posted on • Edited on

Gmail Validation

how i validate the given gmail is valid or invalid.

Condition :
Gmail end should end like this "@gmail.com"
so, I first checked last 10 character from given gamil.

If condition is false return"gmail end should end like @gmail.com"

If condition is True, checks the next condition

next take the gmail copy except "@gmail.com"
the gmail copy is only have charactors and numbers and plus and dot.
the condition is true return "valid"
the condition is false return "special charector not allow"

def verify_Gmail(Gmail):
    if Gmail[-10:]=="@gmail.com":
        i=0
        gmailcopy=Gmail[0:len(Gmail)-10]
        while i<len(gmailcopy):
            current=gmailcopy[i]
            i+=1
            if current>="a" and current<="z":
                continue;
            elif current>="A" and current<="Z":
                continue;
            elif current>="0" and current<="9":
                continue;
            elif current=="." or current=="_":
                continue;
            else:
                return "special charector not allow"
        return "valid"
    else:
        return "gmail end like this @gmail.com "

print(verify_Gmail(input("Enter Your Gmail :")))

Enter fullscreen mode Exit fullscreen mode

Top comments (0)