0

I have 3 list Balance, Credit and Debit

balance = [5968569.1, 6010085.1, 6059904.1, 6088646.1, 6137157.1, 6158157.1, 6211282.1, 6259407.1, 6298292.1, 6344796.1, 376796.1, 376746.1, 376741.6, 376737.1]
credit = [0.0, 41516.0, 49819.0, 28742.0, 48511.0, 21000.0, 53125.0, 48125.0, 38885.0, 46504.0, 0.0, 0.0, 0.0, 0.0]
debit = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5968000.0, 50.0, 4.5, 4.5]

I am trying to check if the reconcillation is right or not,Find my code below:

count = 0
check_bal = []
bal = None
updated_bal = None

for i in range(len(balance)):
  if credit[count] == 0.0 and debit[count] == 0.0 and balance[count] != 0.0:
    bal = balance[count]
    check_bal.append(bal)
    count+=1
  elif credit[count] != 0.0 and debit[count] == 0.0 and balance[count] != 0.0:
    updated_bal = float(bal) + float(credit[count])
    bal = updated_bal
    updated_bal = None
    check_bal.append(bal)
    count+=1
  elif credit[count] == 0.0 and debit[count] != 0.0 and balance[count] != 0.0:
    updated_bal = float(bal) - float(debit[count])
    bal = updated_bal
    check_bal.append(bal)
    updated_bal = None
    count+=1

And here is the Output:

5968569.1
6010085.1
6059904.1
6088646.1
6137157.1
6158157.1
6211282.1
6259407.1
6298292.1
6344796.1
376796.0999999996
376746.0999999996
376741.5999999996
376737.0999999996

Why it's float values giving bizzare result?? While when I am adding it's giving expected result

0 Answers0