escape sequences in list comprehensions

Bruno Desthuilliers bdesth.quelquechose at
Fri Nov 12 18:47:09 CET 2004

kartik wrote:
> Escape sequences don't seem to work in strings within list comprehensions:
>>>>print ['%s\n' %i for i in [1,2,3]]
> ['1\n', '2\n', '3\n']
> What am I missing?

Other have answered to this question.

Just try this instead :
   print "\n".join(["%d" % i for i in [1,2,3]])

> Thank you.

More information about the Python-list mailing list