View the step-by-step solution to:

This is my Python code. When it runs, the shell restarts.

This is my Python code. When it runs, the shell restarts. Can you help me understand what might be causing this


class Automobile():

  __make = ""

  __model = ""

  __color = ""

  __year = 0

  __mileage = 0

   

   

  def __init__(self, make = None, model = None, color = None, year = None, mileage = None):

    self.make = make

    self.model = model

    self.color = color

    self.year = year

    self.mileage = mileage


  def add_vehicle(self):

    auto = Automobile()

    vehicle_file = open('vehicle.txt', 'a')

    make = input("Enter make: ")

    model = input("Enter model: ")

    color = input("Enter color: ")

    year = input("Enter year: ")

    mileage = input("Enter mileage: ")

     

    vehicles = Automobile(make, model, color, year, mileage)

    vehicle_list = [vehicles.make, vehicles.model, vehicles.color, vehicles.year, vehicles.mileage]

     

    for item in vehicle_list:

      vehicle_file.write("%st" % item)

    vehicle_file.write("n")

    vehicle_file.close()

    print("Your record has been succesfully added to the inventory")

     

  def delete_vehicle(self):

    del_rec = input("Enter record to delete: ")

         

    with open("vehicle.txt","r+") as f:

      new_f = f.readlines()

      f.seek(0)

      for line in new_f:

        if del_rec not in line:

          f.write(line)

      f.truncate()

    print("Succesfully deleted record from inventory")

     

  def set_make(self, make):

    self.make = make

     

  def get_make(self):

    return self.make

   

  def set_model(self, model):

    self.model = model

     

  def get_model(self):

    return self.model

   

  def set_color(self, color):

    self.color = color

     

  def get_color(self):

    return self.color

   

  def set_year(self, year):

    self.year = year

     

  def get_year(self):

    return self.year

   

  def set_mileage(self, mileage):

    self.mileage = mileage

     

  def get_mileage(self):

    return self.mileage

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question