我正在尝试使用 for 循环对列表进行排序和比较,但我不断收到错误消息:
排序(列表[str(y + 1)])
KeyError:'14454'
这是我的代码:
l = 0
k = 0
u = 0
lista = {}
sys.stdout = open("1.txt", "w")
for i in range(1,28):
for j in range(1,28):
for k in range(1,28):
a = float(i)
b = float(j)
c = float(k)
q = (a*b*c) / ((a+b+c)*(a+b+c)*(a+b+c))
if q > (1 / 81) and q < 1:
if a != b and b != c and c != a:
lista[str(l)] = [a,b,c]
l = l + 1
for x in range(l):
for y in range(l):
sorted(lista[str(x)])
sorted(lista[str(y+1)])
if lista[str(x)] == [str(y+1)]:
u = u + 1
sys.stdout.close()