I need a little help with this while loop. I have my Initial balance and a current balance. Is what I am trying to do is after the first initial balance the current balance needs to become the Initial and so on.
InitalPrice = float(input("Enter the Price of the Computer: "))
Month = 0
AnInterest = (InitalPrice - InitalPrice * .10) * .01 / 12
MonthlyPayment = (InitalPrice - InitalPrice * .10) * 0.05
Principal = MonthlyPayment - AnInterest
print("%0s%20s%20s%20s%13s%23s" %("Month", "Current Balance", "Interest Owed", "Principal Owed", "Payment", "Balance Remaining"))
while MonthlyPayment >= 0:
Month += 1
InitalPrice = InitalPrice - InitalPrice * .10
Balance = InitalPrice + AnInterest - MonthlyPayment
print("%0d Months%20.2f%20.3f%20.2f%13.2f%23.2f" %(Month, InitalPrice, AnInterest, Principal, MonthlyPayment, Balance))
if Balance <= 0:
break
MonthlyPayment >= 0as the condition for thewhileloop, but never changingMonthlyPaymentat any point. That means the condition will always be true (if it was true at the start) and so the loop will never end. Probably you want to be checking ifBalanceor something related is positive instead.MonthlyPayment >= 0toInitialPrice, I know there are some errors, but I'm an basically making a program take the price of an item and figures the monthly payment, principal, intrest. The initial Price is the price after the 10% down Payment. I need the program run until all payments are made and the remaining balance is zero. I'm just trying to fix one thing at a time.MonthlyPaymenton each loop iteration, but it's unclear.