+ 1
Why the below code is printing object address instead of object content?
IDE: i am using pycharm to run the below code. Ver: Python 3.7 and above Code Snippet: class Point: def __init__(self, x =1 ,y =1 , z=1): self.x=x self.y=y self.z=z def ___str___(self): return f'x: {self.x} , y: {self.y}, z:{self.z}' p1 = Point(4,2,9) def f1(): print(p1) f1() Expected: x: 4, y:2, z:9
2 Respostas
+ 1
Try this: https://code.sololearn.com/cWV8UNcj43Xh/#py
You called to print the Address, but didn't called the ___str___() function. Ask for more details.
0
its __str__ not ___str___