[FIXED] Keyword argument in python class

Issue

class Car:
   def __int__(self, **kw):
          self.make = kw["make"]
          self.model = kw["model"]

my_car = Car(make="Nissan", model="GT-R")
print(my_car.model)

TypeError: Car() takes no arguments, even though I initialized it as a multiple keyword argument


Solution

You misspelled "init". That should fix it :)



Answered By - farzany
Answer Checked By - Marie Seifert (Python.Easybugfix Admin)

Related Posts

Post a Comment