[NooB] a Variable in multiple quotes...

Fredrik Lundh fredrik at pythonware.com
Mon Feb 14 17:09:43 EST 2005


"administrata" wrote:

>> Oh: from the subject line, I'm guessing that you want it to say "John
>> used to love pizza" instead? In that case, try doing this:
>>
>> I = "John"
>> print "%s used to love pizza" % I
>
> How can I do it with several variables?
>
> About 10 or more...

two:

    print I, "used to love", J

or

    print "%s used to love %s" % (I, J)

three:

    print I, "used to", J, K
    print "%s used to %s %s" % (I, J, K)

five:

    print I, J, "to", K, L, M
    print "%s %s to %s %s %s" % (I, J, K, L, M)

(you get the idea)

for more on this, and some variations, read the "fancier output
formatting" chapter in the tutorial again:

    http://docs.python.org/tut/node9.html

(you've read the tutorial before, right?)

</F> 






More information about the Python-list mailing list