-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplates.py
58 lines (52 loc) · 1.14 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
def main():
plate = input("Plate: ").strip()
if is_valid(plate):
print("Valid")
else:
print("Invalid")
def is_valid(s):
s = str(s)
validated = ""
numcheck = 0
illegal_symbols = [
" ",
".",
"?",
"!",
",",
":",
";",
"(",
")",
"[",
"]",
"'",
"-",
'"',
"/",
"\\",
"`",
"@",
"#",
"*",
]
if len(s) >= 2 and len(s) <= 6:
if s[0].isalpha() and s[1].isalpha():
for ch in s:
if ch not in illegal_symbols:
if ch.isnumeric() and numcheck == 0 and ch != "0":
numcheck += 1
validated += ch
elif ch.isnumeric() and numcheck > 0:
numcheck += 1
validated += ch
elif ch.isalpha() and numcheck < 1:
validated += ch
else:
return False
if validated == s:
return True
else:
return False
if __name__ == "__main__":
main()