0
Why it show attribute error? Help to me fix the code
class a: _egg = 5 def tot(self): print(self._egg) onj = a() onj.tot print(onj._a__egg)
5 Respuestas
+ 1
The tot() method (and its body block) is not properly indented, thus it was not recognized as a member of class 'a'
+ 2
In SoloLearn or not, indentation always works for me though ...
+ 2
Amala Yakin
Indentation always works in Sololearn.
A class has attribute _egg not _a_egg
class a:
_egg = 5
def tot(self):
print(self._egg)
onj = a()
onj.tot()
print(onj._egg)
0
Use egg as variable not _egg
- 2
Yeah bro your answer is correct , but in sololearn sometimes indentation not working, that's main reason ...