I’m lost, I gone over python class tutorials at least a dozen times and I just cant get anything to work. Can anyone explain why this simple program is not working.
class TestName:
def init(self):
self.list_test = list_test
def return_list(self):
return len(list_test) - 1
r1 = TestName([1,2,3,4,5])
print (r1)
Traceback (most recent call last):
line 7, in
r1 = TestName([1,2,3,4,5])
TypeError: TestName() takes no arguments
EDIT*
ok I kind fixed it
class TestName:
def init(self, list_test):
self.list_test = list_test
def return_list(self, list_test):
return len(list_test) - 1
test_list1 = [1,2,3,4,5]
r1 = TestName(test_list1)
print (r1.return_list(test_list1))
Another question would be why do I need enter “test_list1” twice?