Python Print Displays -
i having problem project i'm working. problem having @ end of display list getting negative number, wondering if give me direction on how fix problem? need zero.
initalprice = float(input("enter price of computer: ")) month = 0 downpayment = initalprice * .10 balance = (initalprice - downpayment) aninterest = balance * .01 / 12 monthlypayment = balance * 0.05 print("%0s%20s%20s%20s%13s%23s" %("month", "current balance", "interest owed", "principal owed", "payment", "balance remaining")) in range(1, 100): #aninterest = aninterest if balance >= 0: initalprice = initalprice - initalprice * .10 principal = monthlypayment - aninterest balance = balance + aninterest - monthlypayment print("%0d%20.2f%20.3f%20.2f%13.2f%23.2f" %(i, initalprice, aninterest, principal, monthlypayment, balance))
you subtracting constant amount monthlypayment (ie. 10% of balance). if balance plus interest less monthlypayment balance becomes negative. have simple check see not case.
p.s. recommend using while loop problem loop can either iterate many times, or not enough times.