0
I'm a python begginer...what I did wrong in this.. Why I don't get any output
Class Do(object): def __init__(self,name,age): self.name= name self.age = age def sit(self): print (self.name.title(),"is sitting") def roll_over(self): print(self.name.title(),"is rolling overcome there") My_dog = Dog("Suji",12) My_dog.name
3 odpowiedzi
+ 4
Use print(My_dog.name)
print() is used to get console output.
Your last two lines of code don't belong to your class block so you shouldn't indent it.
Also you forgot a g in dog class name.
https://code.sololearn.com/cRJ8J2EfPe7D/?ref=app
+ 3
class Dog:
def __init__(self,name,age):
self.name= name
self.age = age
def sit(self):
print (self.name.title(),"is sitting")
def roll_over(self):
print(self.name.title(),"is rolling overcome there")
My_dog = Dog("Suji",12)
print(My_dog.name)
+ 2
Thank you friends 😊