[Tutor] Need to be taught a trick or two about printing in neat columns
Dick Moores
rdm at rcblue.com
Thu Nov 2 21:19:33 CET 2006
At 11:33 AM 11/2/2006, Markus Rosenstihl wrote:
>Try somthing like this:
>
>In [32]: a=range(100)
>In [33]: for i in range(0,len(a)):
> ....: print '%-27s'%a[i],
> ....: if (i+1)%3 == 0: print "\n"
>
>0 1 2
>
>3 4 5
>...
>93 94 95
>
>96 97 98
>
>99
>
>
>Note the comma after the first print statement
Yes, thanks, but the reason I wanted 3 columns was to compress the
height of the list printout for the user, so I don't want all those
blank lines.
Dick
More information about the Tutor
mailing list