Use the following code as a way to express the entered mistakes up to 2 decimal places.
a = float(input())
print('%.2f' % a)
However, I don't know how to write only the format() function with % without .
a = float(input())
print('{%.2f}'.format(a))
When executing the above code
Traceback (most recent call last):
File "<pyshell#108>", line 1, in <module>
print('{%.2f}'.format(a))
KeyError: '%'
This error message has been received.
How can I set various settings like above with format() only without %?
python3.6.2 python
© 2024 OneMinuteCode. All rights reserved.