-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplates.py
71 lines (60 loc) · 1.32 KB
/
plates.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
59
60
61
62
63
64
65
66
67
68
69
70
71
def main():
plate = input("Plate: ")
if is_valid(plate):
print("Valid")
else:
print("Invalid")
def is_valid(x):
special = [
"~",
"!",
"@",
"#",
"$",
"%",
"^",
"&",
"*",
"(",
")",
"-",
"_",
"+",
"=",
" ",
]
r = [*x]
for d in range(len(r)):
if r[d] in special:
return False # "character present"
else:
d = d + 1
else:
if len(r) > 6 or len(r) < 2:
return False # "length"
else:
for n in range(len(r) - 1):
try:
r[n] == int(r[n])
break
except ValueError:
n = n + 1
if n == (len(r) - 1):
# print(0)
return True
if int(r[n]) == 0:
return False # "1st number zero"
else:
new = n + 1
for new in range(n + 1, len(r)):
# print(r[new])
try:
r[new] == int(r[new])
except ValueError:
return False # "middle number"
else:
new = new + 1
else:
return True
if __name__ == "__main__":
main()