Regarding OOPS (not print class)

sir/mam, after running below program not show print description() or any error why?

class cat:
def init(self,name,age):
self.name=name
self.age=age

def description(self):
    print("cat name is:",self.name)
    print("cat age is:",self.age)
    
    x=dog("mahi",5) 
    x.description()


1 Like

Hello @ashish26meshram

The first solution is stop the kernel and try doing it

The second solution is - the constructor should be called like init . in your code “_” this is missing

class cat :
def init(self,name,age):
self.name=name
self.age=age

def desc(self):
    print("Cat name is ",self.name)
    print("Cat age is",self.age)

s = cat (“mahi”,4)
s.desc()

2 Likes