0
Why i am getting AttributeError ?
class Mobile(): def __init__(self,model): self.model=model def show_model(self): print('Model',self.model) realme=Mobile("hello").show_model() print(realme.model) print(realme.model)
3 Antworten
+ 3
Because the realme variable refers to a method not an instance of a class.
Its just saying take off the ".show_model()" call on line 6 and make it like:
realme = Mobile("hello")
# then print its model
print(realme.model) OR realme.show_model()
+ 3
Varun show_model() will return None and that's why the value of realme variable will be None