If I understood the docs correctly, in python 2.6.5 string formatting \"{0:d}\" would do the same as \"%d\" with the String.format() way of formatting strings
That error is signifying that you are passing a float to the format code expecting an integer.
Use {0:f}
instead. Thus:
"I have {0:f} dollars on me".format(100.113)
will give:
'I have 100.113000 dollars on me'
Yes, you understand correctly. However you are passing float
(i.e. 100.113
), not int
. Either convert it to int
: int(100.113)
or just pass 100
.
delete 'd', since the object type might not be a number as in my case