printing with variable length of list

Riccardo Galli riccardo_cut-me at cut.me.sideralis.net
Mon Oct 18 21:12:31 CEST 2004


On Mon, 18 Oct 2004 11:55:20 -0700, les ander wrote:

> Hi,
> suppose I have a list
> d=[1.2 , 31.1, 1.001]
> in general i will not know the size of d
> however, I would like to print them out nicely in the row format
> such as:
> print "%-10f "* len(d) % d
> 
> however, the above line does not work--python says that float
> argument is required.

You need a tuple, not a list
print "%-10f "* len(d) % tuple(d)

Riccardo

-- 
-=Riccardo Galli=-

 _,e.
s~  ``
 ~@.   ideralis Programs
.   ol 
 `**~  http://www.sideralis.net



More information about the Python-list mailing list