Код: Выделить всё
while check == 1:
monthly_payment = float(input("Enter how much you can pay per month: "))
annual_interest = float(input("Enter the bank's annual interest rate (in %): "))
years = input("Enter how many years you want the loan for: ")
r = annual_interest / 100 / 12
n = years * 12
if r == 0:
loan_amount = monthly_payment * n
else:
loan_amount = monthly_payment * (1 - (1 + r) ** -n) / r
print("\n-----------------------------")
print("Maximum loan amount you can get: "+str(round(loan_amount, 2)))
print("-----------------------------")
check = input("Do you want to do the calculation again? 1 - yes 0 - no: ")
Код: Выделить всё
Traceback (most recent call last):
File "C:\Users\Alex\PyCharmMiscProject\test3.py", line 13, in
loan_amount = monthly_payment * (1 - (1 + r) ** -n) / r
^^
TypeError: bad operand type for unary -: 'str'
Подробнее здесь: https://stackoverflow.com/questions/798 ... hon-script
Мобильная версия