下面的代码检查前5位数之和是否等于接下来的5位数。并打印相应的密钥。但是每次执行它时都会给出不同的输出(在Eclipse luna中)。为什么呢?
dict={"a":1234554321,"b":4561238791,"c":7894598745}
list=[]
list1=[]
sum1=0
sum2=0
str1=""
for key,values in dict.items():
v1=str(values)
for i in v1:
list.append(int(i))
for i in range(0,5):
sum1+=list[i]
for i in range(5,10):
sum2+=list[i]
if sum1==sum2:
list1.append(key)
list.clear()
sum1=0
sum2=0
print(list1)