Oct-04-2018, 04:05 PM
(Oct-04-2018, 04:01 PM)volcano63 Wrote:(Oct-04-2018, 03:49 PM)Irhcsa Wrote: For year 5 I need it to format to the 12th decimal place. I have tried reading the documentation, but it isn't working.
I need str(yearFiveTest) to express to 12 decimals.
The moment you appliedstr
conversion, you made formatting options irrelevant (actually, illegal). The purpose of formatting is to facilitate conversion to string according to specification
Someone will tel you about formatting post, but if you want to develop Python - I strongly suggest to follow PEP-8 conventions
Output:In [2]: '{:.12f}'.format(0.56456454646) Out[2]: '0.564564546460' In [3]: '{:.12f}'.format(str(0.56456454646)) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-3-2e1f324cded6> in <module>() ----> 1 '{:.12f}'.format(str(0.56456454646)) ValueError: Unknown format code 'f' for object of type 'str'
Then how would I do it? I have to make it produce a float to the 12 decimal. Is it not possible?