class Person:
def __int__ (self, name):
self.name = name
def talk(self):
print("talk")
john = Person("John Wick")
print(john.name)
john.talk()`
1 respuesta
Se escribe __init__
Te falto la "i".
La versión correcta:
class Person:
def __init__ (self, name):
self.name = name
def talk(self):
print("talk")
john = Person("John Wick")
print(john.name)
john.talk()
Le pasa a todo el mundo ...
__init__
(abreviatura de initialize) en vez de__int__
(parecido a integer).