'Why is it a TypeError to use an arithmetic expression in %-style print formatting?
I tried to input a float number and output a simple result using two methods:
t = float(input())
print('{:.2f}'.format(1.0 - 0.95 ** t))
print('%.2f' % 1.0 - 0.95 ** t)
The first method worked but a TypeError occurred in the second one:
unsupported operand type(s) for -: 'str' and 'float'.
What's wrong with that?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
