Search code examples
pythonpython-3.xkeyword-argumentargs

Keyword argument in python class


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 :)