Jun-05-2018, 08:50 AM
I write this code & run perfect
class Person: def __init__(self, name, age): self.name = name self.age = age def myfunc(self): print("Hello my name is " + self.name) p1 = Person("John", 36) p2 = Person("Roshan",45) p1.myfunc() p2.myfunc()but when i want to print age in myfunc then program gives me error
class Person: def __init__(self, name, age): self.name = name self.age = age def myfunc(self): print("Hello my name is " + self.name) print("My age is " + self.age) p1 = Person("John", 36) p2 = Person("Roshan",45) p1.myfunc() p2.myfunc()what is wrong with me ?