rizard
1
i know this is dumb question but how can i print [87, 'tyu']
instead of object for this code
class test:
def test1(self, test_list):
self.test_list = [87, 'abc']
def test2(self):
print(self.test_list)
t = test()
print(t.test2)
First, You need to call test1() first, so the list is assigned. You could also put that into __init__
to run when the class is instantiated.
https://www.w3schools.com/python/gloss_python_class_init.asp
Second, right now you are referring to the method, but not calling it. Add ()
to the end to call test2.
print(t.test2())
1 Like
system
Closed
3
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.