[Tutor] help: space formatting for multiplication table

Aaron Elbaz flamesrock at gmail.com
Sat May 14 21:09:48 CEST 2005


I've been racking my brain and am right now feeling nauseous from not
being able to figure out such a simple problem. Here's the code:

#r=10
#line=1
#
#def spaces(r):
#    return r/10
#
#while line-1 < r:
#    for i in range(r):
#        print str((i+1)*line) + ' '*spaces(r),
#    line=line+1
#    print

The idea is to print out a multiplication table on the command line
with numbers lining up in the ones column. I want to eventually
emulate programs like top with their spacing. But this code is mostly
for my amusement. How would you make this work?

-thanks


More information about the Tutor mailing list