0
TypeError: __init__() takes 3 positional arguments but 4 were given. How to fix this error?
7 Antworten
+ 1
just needed to fix the super call. compare with your fixed code
https://code.sololearn.com/c1n8HPZpcU2j/?ref=app
+ 2
Please share your code first.
We don't know what are you talking about??
You have shared your exception only (error)......................
+ 2
class Vehicle():
def __init__(self,name,battery=70):
self.name = name
self.battery = battery
def battery_life(self):
print("It has "+ str(self.battery) + " horsepower")
def name_1(self):
print(self.name + " is my favourite car")
my_car = Vehicle ("corvette c7")
my_car.battery_life()
my_car.name_1()
class Bullet(Vehicle):
def __init__(self,name,battery,color):
super().__init__(name,battery)
self.color = 350
def color1(self):
print("The color is " + str(self.color))
my_bullet = Bullet("Thunderbird", "Matte Black" ,350)
my_bullet.name_1()
my_bullet.battery_life()
my_bullet.color1()
0
꧁༒Rishabh༒꧂ done...
0
No problem Atul
0
Ja Play it still have a problem that when you runs the code the output of last 2 lines are only the first 2 instances in my_bullet = Bullet