0
got attribute error in last line. how?
class student: def __init__(self,name): self.name=name def sayhi(self): print("hi from"+ self.name) s1=student("amy") s1.sayhi()
1 Respuesta
+ 5
Your definition of sayhi should not be made in the __init__() method
try this:
class student:
def __init__(self, name):
self.name = name
def sayhi(self):
print("hi from " + self.name)
s1 = student("amy")
s1.sayhi()
I hope this helps :)