can anyone advise me

micklee74 at hotmail.com micklee74 at hotmail.com
Thu Apr 27 05:48:46 EDT 2006


why the output of this code :
x = 0
while x < 10:
        z = 0
        print x
        x = x + 1
        while z < x:
                print z,
                z = z + 1

is

0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 < ---extra


instead of :
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 9

thanks




More information about the Python-list mailing list