Hi,
i have a 2D list in python which i'm trying to fill using 2 for loops. but the problem is when i finish the filling procedure and i print the values, i find that they are not arrangeed in the order of input.
def funcdist(myarr):
diffs = 0
testarr = []
finarr = []
for hx in range(len(myarr)):
del testarr[:]
for hy in range(len(myarr)):
diffs=0
for ch1, ch2 in zip(myarr[hx], myarr[hy]):
if ch1 != ch2:
diffs += 1
testarr.append(diffs)
finarr.append((testarr))
return finarr
in this case their should be some 0's in the diagonal, but when i print the array after i finish, i found that the 0's are all on the right side of the array. why this is happening?
and another question, how to add a column of 1 as the first column of the array?? i have no idea on how to do this.
Thank you