[Tutor] data type conversion for print statement

Kent Johnson kent37 at tds.net
Tue Sep 25 21:12:16 CEST 2007


Noufal Ibrahim wrote:

> I suppose you could also do but it's a little less readable
> print "%sand this %sneeds to check %s"%tuple([str(x) for x in 
> (val1,val2,val3)])

The %s formatter takes care of the string conversion, the list 
comprehension is not needed. Just use

print "%sand this %sneeds to check %s" % (val1,val2,val3)


More information about the Tutor mailing list