For problem set 1c solution, I am wondering why in line 24 and line 25 it states: if balance <= 0 and break respectively. Furthermore, if you add the line print('The balance is: ', balance) before if balance<=0 in line 24, it will print out a lot of things. Shouldnt it only print 12 lines of balance?
I'm assuming this is Python. The syntax of your print statement suggests Python v. 3.xx. I thought that the MIT 6.00 courses were both Python 2.xx. Anyway, you could also try: print type( balance ) to find out if balance is a list, tuple or whatever. When you print a variable, it's usually a pretty good idea to: print "The balance is: ", str( balance ) That will give you a more informative output.
I see, thanks for the tip. With regards to the if balance<=0, is that statement necessary? I think it runs fine without it. Not sure what that if statement's purpose is for in this case. I attached this file as reference.
This line runs?!: balance += interest - monthly_payment It seriously needs parenthesis. Those two lines provide an escape in case the loan and interest are paid off ( balance <= 0 ) before the loop finishes. Set it up with values that will payoff in say 6 months.
Thank you rsmith for taking the time to clarify. I see now!
Join our real-time social learning platform and learn together with your friends!