I have question about using nested single line for loop in python. In particular, I have the followings:
A = [[tmp1[a][b] / tmp2[a] for b in range(0,10)] for a in range(0,20)]
According to Here, the single line for loop is equivalent as
for a in range(0,20):
for b in range (0, 10):
A.append(tmp1[a][b] / tmp2[a])
However, python gives me the following error:
AttributeError: 'numpy.ndarray' object has no attribute 'append'.
How should I modify the structure so that I use double for loop instead of single line nested for loop?
Update:
A=[]
for a in range(0,20):
B = []
for b in range (0, 10):
B.append(tmp1[a][b] / tmp2[a])
A.append(B)