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)

10th Aug 2020, 9:31 AM
Varun
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()
10th Aug 2020, 9:50 AM
Slick
Slick - avatar
+ 3
Varun show_model() will return None and that's why the value of realme variable will be None
10th Aug 2020, 9:52 AM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar