Oct-04-2018, 04:01 PM
(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 applied
str
conversion, you made formatting options irrelevant (actually, illegal). The purpose of formatting is to facilitate conversion to string according to specification 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'
Someone will tel you about formatting post, but if you want to develop Python - I strongly suggest to follow PEP-8 conventions
Test everything in a Python shell (iPython, Azure Notebook, etc.)
- Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
- Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
- You posted a claim that something you did not test works? Be prepared to eat your hat.