Alexander Birch on 8 Oct 2004 01:26:03 -0000 |
On Thu, 7 Oct 2004 21:19:09 -0400, Jeff Abrahamson <jeff@purple.com> wrote: > I want to do something like this: > > for(i = 0; i < 10; i++) > printf("%10d", ar[i]); > printf("\n"); > > But I want to do it in python. > > I could say > > for i in range(len(ar)): > print "%10d" % ar[i] > > or even > > for d in ar: > print "%10d" % d > > But neither prints to a single line. > > I could build it up as a string and the print, but I don't see how to > format the string properly to get a table with columns. > > Any pointers? Thanks. What if you do: for d in ar: print "%10d" % d, Notice the comma at the end of line -- "We ought to never do wrong when people are looking." --Mark Twain http://lifesabirch.org/humour/fifteen.php ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|