[Tutor] For Loops and nested loops
Umesh Singhal
umeshsinghal at hotmail.co.uk
Sat Aug 16 07:33:42 CEST 2008
Hi im still relatively new to python and i am designing a multiplication table that enables a user to input the size of the times table unfortunately ive stumbled on the nested loops this is what i have right now:
a=raw_input('please enter a number')
b=int(a)
n=b+1
for row in range(1, n):
for col in range(1, n):
print "%3d " % (row * col),
print
the input which comes out is:
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25
however i need something more on the lines of:
| 2 3 4 5
==================
2 | 4 6 8 10
3 | 6 9 12 15
4 | 8 12 16 20
5 | 10 15 20 25
does anyone know what i need the third nested for loop to be ? to make it like the above example. Pleasee help me !!
_________________________________________________________________
Win New York holidays with Kellogg’s & Live Search
http://clk.atdmt.com/UKM/go/107571440/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080816/155bd5cb/attachment.htm>
More information about the Tutor
mailing list