+ 2
Help me out to locate the error.
Hi every one, i am unable to locate the error in this code. Thanks class parrot: #class attribute spec = "bird" #costructor def __init__(self, color, age): self.color = color self.age = age #objects of the class blu = ("green", 9) tom = (" blue", 12) #accessing the objects through class print("The blu is a{}".format(blu.__class__.spec)) print("The tom is also a{}".format(tom.__class__.spec)) print("The parrot blu is a{}colured with age of {} years" . format(blu.color, blu.age)) print("The parrot tom is a{}colured with age of {} years" . format(tom.color, tom.age))
4 Respuestas
+ 2
Najm Aarifeen
blu = ("green", 9)
tom = (" blue", 12)
are just tuples.. Not objects..
Create objects like :
blu = parrot("green", 9)
tom = parrot(" blue", 12)
Hope it helps..
+ 2
Thanks dear friend, i wasted much of my time just to locate .
+ 1
In python, identation is much important. So save code in playground and share link here.. Otherwise it's difficult to find error. And it's not understandable identation errors if any are by typos or unintentional.. Hope you understand..
+ 1
You're welcome...