letters = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
def main():
plate = input("Plate: ")
if is_valid(plate):
print("Valid")
else:
print("Invalid")
def correct_length(word):
lower = word.lower()
if len(word) >= 2 and len(word) <= 6:
return True
def correct_type(word):
x = 0
while x < len(word):
if word[x] not in letters and word[x] not in numbers:
return False
x += 1
else:
return True
def first_two(word):
lower = word.lower()
if lower[0] in letters and lower[1] in letters:
return True
def no_numbers_middle(word):
for i in word:
if word[i] in numbers and word[i+1] in letters:
return False
else:
return True
def cant_start_with_0(word):
stringg = ""
for i in word:
if word[i] in numbers:
stringg = stringg + word[i]
if stringg[0] == "0":
return False
else:
return True
def is_valid(word):
if first_two(word) == True and correct_type(word) == True and correct_length(word) == True and no_numbers_middle(word) == True and cant_start_with_0(word) == True:
return True
main()