On 9/26/07, Christopher Spears <[EMAIL PROTECTED]> wrote:
>
> I'm working on a problem in Chapter 5 of Core Python
> Programming(2nd Edition).  I am supposed to write a
> script that take an opening balance and a monthly
> payment from the user.  The script then displays the
> balance and payments like so:
>
>
> Enter opening balance: 100
> Enter monthly payment: 16.13
>         Amount  Remaining
> Pymnt#  Paid    Balance
> 0       0.00    100.00
> 1       16.13   83.87
> 2       16.13   67.74
> 3       16.13   51.61
> 4       16.13   35.48
> 5       16.13   19.35
> 6       16.13   3.22
> 7        3.22   0.00
>
> Here is what I have written so far:
>
> #!/usr/bin/env python
>
> balance = float(raw_input("Enter opening balance: "))
> payment = float(raw_input("Enter monthly payment: "))
>
> print "\tAmount\tRemaining"
> print "Pymnt#\tPaid\tBalance"
>
> payment_num = 0
> print "%d\t%.2f\t%.2f" % (payment_num,0,balance)
>
> while balance >= 0:
>     payment_num = payment_num + 1
>     if balance > 0:


You have: if balance > 0:

You should be checking whether the remaining balance is greater than the
payment amount, not whether it is greater than 0.
This is probably just a typo as it looks like you're on the right track.


Ian
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to