Why class Car() takes no arguments

My code is:

class Car(object):

	def _init_(self, make, model, year):
		self.make=make
		self.model=model
		self.year=year
		self.odometer_reading=0

	def get_descriptive_name(self):
		long_name=str(self.year)+ ' ' + self.make + ' ' +self.model
		print(long_name.title())

	def read_odometer(self):
		print("This car has " + str(self_odometer_reading) + " miles on it")

	def update_odometer(self, mileage):
		self.odometer_reading=mileage

	def increment_odometer(self, miles):
		self.odometer_reading+=miles

my_new_car = Car('audi', 'a4', 2016)
my_new_car.get_descriptive_name()

The problem is:
Traceback (most recent call last):
File “class_car.py”, line 29, in
my_new_car = Car(‘audi’,‘a4’,2016)
TypeError: Car() takes no arguments

Is init surrounded by one underscore or two? In your code above it looks like only one but it needs to be two underscores.

1 Like

I’ve adjusted the OP’s post to correctly format the code, and thus make it clearer.

Nonetheless, good spot. :+1:

There should be two. Thanks