Mortgage calculator, unable to use variables as integers, to do math formula Mortgage calculator, unable to use variables as integers, to do math formula tkinter tkinter

Mortgage calculator, unable to use variables as integers, to do math formula


I removed self.calculations() from def __init__ because it causes a division by 0.

Then, assuming you want all values to be integers, I changed :

p = p.get()i = i.get()n = n.get()

into

p = int(self.P.get())i = int(self.I.get()) / 100n = int(self.N.get())

because you were not getting the values of from the text fields and "i" was not divided by 100 to make it a scalar from 0 to 1 (which I think should be the case in your formula)

I haven't checked your monthly formula but I think it should be:

divide2 = ((1 + i) ** (n - 1))

and add @MasterOfTheHouse's suggestion and it should be fine!


You should have other issues there (besides the zero division) . Just make a check like this one and then look for the other issues.

payment = 0 if divide2 == 0 else divide1/divide2

This quick-fix worked for me

enter image description here

Hope this helps.