Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

object oriented programing……error eith importing

so like i’m trying to import a module in Python and I did the exact same thing the guy on Youtube did but mine is still not working…..im have two different files "oop.py" and "car.py".
i am trying to import from "car.py" to "oop.py"

class Car:

def __int__(self,make,model,year,color):
    self.make = make
    self.model = model
    self.year = year
    self.color = color


def drive(self):
    print("this car is driving")

def stop(self):
    print("This car has stopped")

the above is "car.py"

from car import Car

car_1 = Car("chevy","standard",2021,"blue")

the above is "oop.py"

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Traceback (most recent call last):
File "C:\Users\ike\PycharmProjects\main\object oriented programming\oop.py", line 3, in
car_1 = Car("chevy","standard",2021,"blue")
TypeError: Car() takes no arguments

Process finished with exit code 1

this is the error i keep getting.
pls what is the problem

>Solution :

To begin with, __int__ should be __init__.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading