I am writing a simple code that should determine the license plates of the car and say if it is of an old or a new type. The user inputs a string (example: "ABC123" or "1234POW") and the program should return a string with a corresponding value: "New" or "Old"
So, the problem is:
l = input("Enter your license plate: ")
if len(l) == 6:
if l[0] and l[1] and l[2] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
if l[3]and l[4]and l[5] in "1234567890":
print("You have a license plate of an old type")
else:
print("The plate is not valid. Check your input")
else:
print("The plate is not valid. Check your input")
elif len(l) == 7:
if l[0:4] in "1234567890":
if l[4:7] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
print("You have a license plate of a new type")
else:
print("Your plate is not valid, check your input+")
else: print("This doesn't look like a valid plate number")
Lines 11 and 12: I have no idea why, but instead of printing the "New Type" message I get "Your plate is not valid, check your input+".
But if I change the line 12 to "if l[4] and l[5] and l[6] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - everything works fine.
Would be grateful for explanation, and I beg my pardon, if I posted something or somehow wrong - I'm new here :D Thank you.