[Tutor] NewBie Question... Variables
Alan Gauld
alan.gauld at freenet.co.uk
Tue Feb 15 19:03:48 CET 2005
> How can I do it with several variables?
> I = "John"
> print "%s used to love pizza" % I
wrap them in parens:
>>> a,b = 3,4
>>> print "%d x %d = %d" % (a,b, a*b)
> About 10 or more...
Same technique but you might find it easier to use labels to
identify the fields.
>>> sum = a+b
>>> print "%(a)d + %(b)d = %(sum)d" % locals()
My tutoroial covers some of this in the Simple Sequences topic.
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list