On Sun, Jan 24, 2016 at 2:20 PM, MRAB <pyt...@mrabarnett.plus.com> wrote:
> The format method, on the other hand, belongs to the format string it's
> attached to. In this example:
>
>     'The new price is {}' .format(newPrice, '.2f')
>
> the format string is 'The new price is {}' and you're calling its 'format'
> method with 2 values for that string, the first being 4.0 (used) and the
> second on being '.2f' (unused).
>
> What you want is:
>
>     print('The new price is {:.2f}'.format(newPrice))

Why doesn't str.format raise an exception when passed extra positional
arguments?
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to