Hey I have this code for some reason It's not working, can you
please help me to run it?
class Automobile:
def __init__(self, make, model, color, year,
mileage):
self.make = make
self.model = model
self.color = color
self.year = year
self.mileage = mileage
def new_car_to_add(self):
self.make =
str(input('Please Enter the Make of the Car'))
self.model = str(input('Please
Enter the Model of the Car'))
self.color = str(input('Please
Enter the Color of the Car'))
self.year =
int(input('Please Enter the Year of the Car'))
self.mileage = int(input('Please Enter
the Number of Miles on the Car'))
def __str__(self):
return('%d %s %s Color: %s Mileage: %d'
%(self.year, self.make, self.model, self.color,
self.mileage))
car_list = []
def add_new_car(car_list):
id = int(input('Enter the id of the car
to update: '))
new_car = car.add_new_car()
new_car = car.__str__()
car_list[id-1] = new_car
print('Car was updated succesfully.
')
def main():
dealershop = True
while dealershop:
print ("""
Read carefully
1 to Add a new Car
2 to Delete a Car
3 to view the inventory
4 to Update the inventory
5 to Output all the cars within the
inventory
6 to Quit""")
choice_made =
input("Choose an Option")
if choice_made ==
1:
car =
Automobile()
car.new_car_to_add
car_list.append(car.__str__())
elif choice_made == 2
:
for i in
car_list:
car_list.pop(int(input('Enter the Id of the car to delete:
')))
print('Delete Successfully')
elif choice_made == 3
:
print(car_list)
elif choice_made == 4
:
add_new_car(car_list)
elif choice_made == 5
:
f =
open('dealershop_inventory.txt', 'w')
f.write(str(car_list))
f.close()
else :
print("Please Try Again")
main()
Hey I have this code for some reason It's not working, can you please help me to run it? class Automobile: def __in
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Hey I have this code for some reason It's not working, can you please help me to run it? class Automobile: def __in
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!