123456789101112131415161718192021222324252627282930313233343536373839 |
- import re
- def main():
- plate = input("Plate: ")
- if is_valid(plate):
- print("Valid")
- else:
- print("Invalid")
- def is_valid(s):
- if len(s) < 2 or len(s) > 6:
- return False
- return re.match(r"^[A-Z]{2,}([1-9]\d+)?(?![A-Z])$", s) is not None
- def loopy_is_valid(s):
- length = 0
- has_digits = False
- for n, c in enumerate(s):
- if n > 6:
- return False
- if not c.isalnum():
- return False
- if n < 2 and not c.isalpha():
- return False
- if c.isdigit():
- if not has_digits and c == '0':
- return False
- has_digits = True
- elif has_digits:
- return False
- length += 1
- return length >= 2
- if __name__ == "__main__":
- main()
|