There is a code:

print("Сумма вашего кредита {0:.2f} за период {1:d} месяцев. Ежимесячный взнос, составит {2:.2f} "+\ "в меясяц процент банка ежимесячно составит {3:.2f} !".format(creditSum, period, result, bankProcent)) 

Displays only the last value adequately, all others as a string. Explain what is the error?

  • The required minimum code on which the problem is reproduced. According to the given data - fortune telling on the tea leaves. - Vladimir Martyanov
  • remove `+ \` (to combine constants) - jfs

1 answer 1

Take a close look at your code:

 print("Сумма вашего кредита {0:.2f} за период {1:d} месяцев. Ежимесячный взнос, составит {2:.2f} "+\ "в меясяц процент банка ежимесячно составит {3:.2f} !".format(creditSum, period, result, bankProcent)) 

You glue two strings together, with the format method being applied only to the second.

  • one
    Solution: s = "...{}...{}..." + "...{}...{}..." print(s.format(...) - andy.37