0

The bellow code checks whether the sum of first 5 digits is equal to next 5 digits or not. And prints the respective key. But it gives different output each time I execute it(in Eclipse luna). Why?

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)
Prasad
  • 1
  • 1

0 Answers0