The legitimacy of the vin is irrelevant. I just want to make sure that the user only enters 17 digits. This is what I have so far:
#Automobile Inventory
print('Automobile Inventory')
class Automobile:
def __init__(self):
self._make = ""
self._model = ""
self._year = 0
self._color = ""
self._mileage = 0
self._vin = ""
def addVehicle(self):
try:
self._make = input('Enter vehicle make: ')
self._model = input('Enter vehicle model: ')
self._year = int(input('Enter vehicle year: '))
self._color = input('Enter vehicle color: ')
self._mileage = int(input('Enter vehicle mileage: '))
self._vin = input('Enter vehicle vin number: ')
if len(self._vin) == 17:
print("ERROR: Vin must be 17 digits or less.")
return True
except ValueError:
print("ERROR: Year and mileage must be numerical")
return False
def __str__(self):
return '\t'.join(str(x) for x in [self._make, self._model, self._year, self._color, self._mileage, self._vin])
Try this:
I made some inline comments where I made changes.