-
Notifications
You must be signed in to change notification settings - Fork 0
/
usernameValidator.py
58 lines (51 loc) · 1.08 KB
/
usernameValidator.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
50
51
52
53
54
55
56
57
58
import string
def validator_arg_1(name):
if len(name) <= 25 and len(name) >= 4:
return True
else:
print('Please Enter A Username with More than 4 and Less than 25 chracters.')
return False
def validator_arg_2(name):
name = [i for i in name]
if name[0] in string.ascii_letters:
return True
else:
return False
def validator_arg_3(name):
lst = [i for i in string.ascii_letters]
lst += [i for i in str(string.digits)]
lst += '_'
list1 = []
name = [i for i in name]
for i in name:
if i in lst:
list1.append(i)
else:
return False
if len(list1) == len(name):
return True
else:
return False
def validator_arg_4(name):
name = [i for i in name]
if name[-1] == '_':
return False
else:
return True
x = input("Enter Your Username :")
def validator(x):
for i in range(2):
if validator_arg_1(x) == True:
if validator_arg_2(x) == True:
if validator_arg_3(x) == True:
if validator_arg_4(x) == True:
return True
else:
return False
else:
return False
else:
return False
else:
return False
print(validator(x))