Ошибка Traceback (most recent call last):
File "main.py", line 20, in
D[i] += math.fabs(math.fabs(A[i][j]) - (A[i][j])**2)
TypeError: 'float' object is not iterable
Помогите исправить
Код:
import math
A = []
n = 8
m = 7
A = [[n + m for m in range(m)] for n in range(n)]
D = [[n] for n in range(n)]
print("Array A:")
for i in range(0, n):
print()
for j in range(0, m):
A[i][j] = math.exp(i / (j + 1)) / (i + 1)
print("{:6.6f}".format(A[i][j]), end = " ")
print("\n")
print("All the distances:")
for i in range(n):
for j in range(m):
D[i] += math.fabs(math.fabs(A[i][j]) - (A[i][j])**2)
print("{:6.6f}".format(D[i]), end = " ")
print()
max = D[0]
maxI = 0
for i in range(n):
if D[i] > max:
max = D[i]
maxI = i
print("The biggest distance from first row is:", "{:6.6f}".format(max))
print("Index of this distance is:", maxI)