Try this:
def main(data):
total = []
n = len(data)
for i in range(n):
tmp = []
for j in range(n):
a = data[i];
b = data[j]
tmp.append(dist(data[i],data[j]))
total.append(tmp)
return total
def dist(a,b):
tmp = [pow(a - b,2) for a, b in zip(a, b)]
return pow(sum(tmp),0.5);
def output(t):#this function is not necessary and is just for tidiness
n = len(t)
for i in range(n):
for j in range(n):
print t[i][j],"\t\t\t",
print "\n"
data = [[1,1,1],[1,2,3],[0,0,0]]#just for test
t = main(data)
output(t)