I am puzzled:
class lin_reg:
def __init__(self):
''' Executes the program '''
Indep_Array, Dep_Array = self.Prob_Def()
Total_Array = Indep_Array.append(Dep_Array)
print Indep_Array, Dep_Array, Total_Array
NumArray = len(Total_Array)
def Prob_Def(self):
Analy_Type = raw_input('Type of Regression(linear-n,nonlinear-nl): ')
Num_IndepVar = eval(raw_input('Number of Independent Variables: '))
Indep_Array = []
for IndepVar in range(Num_IndepVar):
ArrayInput = eval(raw_input('Enter the array: '))
Indep_Array.append(ArrayInput)
Dep_Array = eval(raw_input('Enter the dependent array: '))
return Indep_Array, Dep_Array
When I run this code, I get output as follows:
obs=lin_reg.lin_reg()
Type of Regression(linear-n,nonlinear-nl): nl
Number of Independent Variables: 3
Enter the array: [1,2,3]
Enter the array: [2,3,4]
Enter the array: [3,4,5]
Enter the dependent array: [5,6,7]
[[1, 2, 3], [2, 3, 4], [3, 4, 5], [5, 6, 7]] [5, 6, 7] None
Traceback (most recent call last):
File "<pyshell#18>", line 1, in <module>
obs=lin_reg.lin_reg()
File "C:\Python27\DataAnalysis\lin_reg.py", line 13, in __init__
NumArray=len(Total_Array)
TypeError: object of type 'NoneType' has no len()
How is the dependent array Dep_Array
automatically appended to Indep_Array
and why is Total_Array
returning None
?
I was expecting to see output like this for above input: [[1,2,3],[2,3,4],[3,4,5]] [5,6,7] [[1,2,3],[2,3,4],[3,4,5],[5,6,7]]