0
why is it not working?
class vehicle : def __init__(self, nof, lenght) : self.nof = nof self.length = lenght def wcap(self): n = self.nof l = self.lenght return n * l * 100 class bus(vehicle) : def __init__(self, length): super().__init__(length ,length) class car(bus): def __init__(self, length): super().__init__(length, length) def maxpass(self) : a = self.lenght return a *3 class mc(vehicle) : def maxspeed(self): l = self.length n = self.nof return (l * n)**3 class bike(mc) : def intro(self): return "Bikes are mcs without the heavy engine!" a = car(1,2)
11 Respostas
+ 2
I am not sure why, but like this it runs without errors,
class car(bus):
def __init__(self, length):
super().__init__(length)
I think because class bus has only one argument, class car should init with only one.
+ 6
Car takes one parameter
Car inherits from bus. Bus init must be called with one parameters.
Bus inherits from vehicle and vehicle init must be called with 2 parameters.
+ 4
Car only takes one parameter, the length. You supply 2
+ 3
You should put the code here. I have no idea what you're doing
+ 3
Correct the spelling of length in the 2nd and 4th lines of your codes
+ 1
Put it in Code Playground and run there. It will show the errors.
Plus, link your code in the question. This way, others can test it and possible solutions.
+ 1
Me too. Python code is not worked...
0
Slick Got error with one also
0
For âlengthâ you keep misspelling until class bus(vehicle) :, and did you mean ânotâ for ânofâ?
0
Lenoname Understand that "Is not working" and "got error" describe the problem in a way that leaves everyone else in a position to only guess.
Pls explain what is not right. Do you get errors? So pls tell which ones. The output is not as expected? Which are the expected and actual outputs?
Also, include in your question a link to your code in Code Playground. It helps debugging.
In short: don't make it so hard to help you.