Printing strings

Michael Hudson mwh21 at cam.ac.uk
Tue Nov 2 10:33:12 EST 1999


Matthew Hirsch <meh9 at cornell.edu> writes:

> Hi All,
> 
> I'm trying to do something like the following:
> 
> a=4.0
> b=2.0
> print '2(%3.1f)' % a,b

ITYM

print 2*'%3.1f ' % (a,b)

the above is being parsed:

print (2(%3.1f)'%a),b
 
> where I really mean
> 
> print '%3.1f %3.1f' % a,b
> 
> but it's printing
> 
> 2(4.0) 2.0
> 
> Is there a way of doing this so I don't have to write out %3.1f,
> multiple times?
> 
> Thanks,
> Matt

hth,
Michael




More information about the Python-list mailing list