none - output

Terry Reedy tjreedy at udel.edu
Sat Nov 9 17:58:04 EST 2002


"Christian Stockhammer"
<christian.stockhammer at students.uni-linz.ac.at> wrote in message
news:1036864302.150371 at news.liwest.at...
> Hello List!

Hello Christian

> I wrote a litte program that will print out the rates of a credit,
but i
> face some problems. Here is the code:
>
> schuld = 100000.0
>
> zinsfaktor = 5.0
>
> tilgung = 20000.0
>
> def tilgungsplan(schuld, zinsfaktor, tilgung):

Guessing payment plan, principle, interest%, payment

> print "Periode Restschuld Zinsen Tilgung"
>
> for i in range(0,5):
>
> zinsen = (schuld*zinsfaktor)/100

Divide %interest by 100 once before loop

> echtetilgung=tilgung-zinsen
>
> i = i + 1

This should almost certainly not be here.  I is automatically
incremented.
Perhaps you want range(1,6)?

> schuld = schuld - echtetilgung
>
> print i," "," ", schuld," ", zinsen," ", echtetilgung

Just so you know, tabs in newsgroup articles disappear for some
readers.  If you want everyone to to read your code without guessing,
use spaces.

> print tilgungsplan(schuld, zinsfaktor, tilgung)

This is your problem.  If you do not specify  return value, Python
functions return None (the object named None with value None).  Remove
'print ' and all will be better.  Or have function return a value

> print "Restzahlung: ", schuld

> None
> My problem is that the "None" (I do not know how to avoid this
output!)

See above.

> and  the value for "Restzahlung" (how much is still left to pay) is
not correct!

Can't say why for sure without seeing your indentation. Try without
i=i+1.


Terry J. Reedy





More information about the Python-list mailing list