So I am trying to add all the columns of a 2D array except for the first two columns of the array. If the sum of the row is greater than or equal to 9 and less than 12, I want the function to print the row. Here is a sample of my 2D array that is a list of lists:
[[12606.000, 74204.000, 1.000, 1.000, 1.000, 1.000, 1.000, 0.000, 0.000],
[12606.000, 105492.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 1.000],
[12606.000, 112151.000, 1.000, 1.000, 0.000, 0.000, 0.000, 0.000, 0.000],
[12606.000, 121896.000, 0.000, 0.000, 0.000, 0.000, 0.000, 1.000, 0.000]]
(Some columns were deleted for formatting). Here is my code:
def sumBinRow(A):
"""Returns the list of employees recording data for at least nine months and fewer than twelve.
"""
for i in range(len(A)):
for j in range(len(A[i])):
if 9 <= sum(A[i][j+2]) <12:
print A[i]
I keep getting a "Type Error" saying the 'int' object is not iterable.