-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEMAIL VALIDATION USING STRINGS.py
53 lines (36 loc) · 1.38 KB
/
EMAIL VALIDATION USING STRINGS.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
# coding: utf-8
# In[1]:
#EMAIL VALIDATION USING STRINGS
email = input("Write your email: ")
k, j, d = 0, 0, 0 # Flags
if len(email) >= 15: #email limit
if email[0].isalpha(): #first character should be a letter
if ("@" in email) and (email.count("@") == 1): # only single '@'
if email[-4] == "." or email[-3] == ".": # posotion of '.'
for i in email:
if i.isspace(): # check any space
k = 1
elif i.isalpha(): #all letters
if i.isupper(): #no uppercase letters allowed
j = 1
elif i.isdigit(): #allow digits
continue
elif i == "_" or i == "." or i == "@": #allow _, ., @
continue
else:
d = 1
#check if any of the flags are set to 1
if k == 1 or j == 1 or d == 1:
print("Wrong email, try again")
else:
print("Right email")
else:
print("Wrong email, try again")
else:
print("Wrong email, try again")
else:
print("Wrong email, try again")
else:
print("Wrong email, try again")
# In[ ]: