Give List to Format String - How To

gregpinero at gregpinero at
Thu Sep 6 04:50:01 CEST 2007

On Sep 5, 10:47 pm, "gregpin... at" <gregpin... at>
> 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'


More information about the Python-list mailing list