Проблема:
Чтобы номер считался действительным, он должен содержать не более 6 букв или цифр, хотя первые два символа должны быть буквами. Если используются цифры, они не могут начинаться с цифры 0, например, CS50 приемлем, CS05 — нет, номера должны находиться в конце таблички, чтобы считаться действительными, например CS50A недопустим. Предположим, что вводимые пользователем данные будут в верхнем регистре.
Код: Выделить всё
def main():
plate = input("Plate: ")
if is_valid(plate):
print("Valid")
else:
print("Invalid")
#checks that the first two digits are letters, that the length of word is no more than 6 characters and
#that the last four digits are either letters or numbers, if numbers are used the is_num_used function is called to make sure the
#first digit entered isn't zero. Numbers are optional for the plate, but if used they have to be at the end and cant start with 0.
def is_valid(s):
for i in range(len(s)):
if s[0:2].isalpha() and len(s)
Подробнее здесь: [url]https://stackoverflow.com/questions/78368744/cs50p-possibly-condition-issues-in-is-valid-function-with-cs50p-problem-set-2[/url]