All Courses

Getting this error

By Manerushi149gmailcom, a year ago
  • Bookmark
0

Getting this error...pls explain 

Code:

class Vehicle:
    def __init__(self,max_speed,mileage):
        self.max_speed = max_speed
        self.mileage = mileage
    def display(self):
        print(f'max_speed - {self.max_speed} and mileage - {self.mileage}')
car = Vehicle("car",45,15)
car.display()

output:

TypeError                                 Traceback (most recent call last)
Cell In [3], line 7
      5     def display(self):
      6         print(f'max_speed - {self.max_speed} and mileage - {self.mileage}')
----> 7 car = Vehicle("car",45,15)
      8 car.display()

TypeError: Vehicle.__init__() takes 3 positional arguments but 4 were given

Error
Typeerror:
Python
Oops
0 Answer
Your Answer

Webinars

More webinars

Related Discussions

Running random forest algorithm with one variable

View More