[Tutor] string formatting

Joel Goldstick joel.goldstick at gmail.com
Sun Sep 18 02:03:18 CEST 2011


On Sat, Sep 17, 2011 at 7:51 PM, Matthew Pirritano <
matthewpirritano at sbcglobal.net> wrote:

> All,****
>
> ** **
>
> I know that I can do this:****
>
> ** **
>
> "the %s is %s" % ('sky', 'blue')****
>
> ** **
>
> But I have very large blocks of text and I thought there was another way
> like****
>
> ** **
>
> X = “sky”****
>
> Y = “blue”****
>
> ** **
>
> "the %(X)s is %(Y)s"
>

Try this:



"the %s is %s" % (X,Y)

> ****
>
> ** **
>
> But I’ve tried this and it is not working. I’m just trying to get it to
> work in the interpreter right now.****
>
> ** **
>
> I’m using python 2.6.5. I need to use this version because it is compatible
> with the software that it is working with (SPSS).****
>
> ** **
>
> What am I missing?****
>
> ** **
>
> Thanks****
>
> Matt****
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>


-- 
Joel Goldstick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110917/7ec0a359/attachment.html>


More information about the Tutor mailing list