Give List to Format String - How To
gregpinero at gmail.com
gregpinero at gmail.com
Wed Sep 5 22:50:01 EDT 2007
On Sep 5, 10:47 pm, "gregpin... at gmail.com" <gregpin... at gmail.com>
wrote:
> I might just be being dumb tonight, but why doesn't this work:
>
> >>> '%s aaa %s aa %s' % ['test' for i in range(3)]
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> TypeError: not enough arguments for format string
>
Ah it just needs a tuple. I posted too soon I guess.
>>> '%s aaa %s aa %s' % tuple(['test' for i in range(3)])
'test aaa test aa test'
-Greg
More information about the Python-list
mailing list