a = float (raw_input ('Enter your full balance:')) b = float (raw_input ('Enter annual interest rate as decimal:')) c = float (raw_input ('Enter the minimal rate as decimal')) d = (a*c) ##balance = d e = (a*c)-(b/12*a) ##principle paid = e f =(e)-(a) ##remaining balance = f for x in range(1,13): print ('month'),(x) print ("Minimum monthly payment $"),(round(d)) print ("Principle paid $"),(round(e)) print ("Remaining balance $"),(round (f)) What part of for loop am I not getting? Indentation? Am I missing' else' or 'if''? I am using 2.5.4
First of all, I suggest naming variables with names, rather than with letters. Like, instead of calling a variable d and comment that d is balance, it is often better to name the variable balance. It costs a little more typing but the benefit of readability outweighs. As for the actual code, note that your output returns the same lines 12 times, except for the month. Your code currently does not change the values of d, e, and f as it runs the for-loop. In other words, the program runs the calculations once, and then prints lines 12 times. Instead, it should calculate 12 times, printing out the results after each calculation.
Thank you for your time: will re-write, Just not getting why it is not calculating 12 times.
Join our real-time social learning platform and learn together with your friends!