Nested Loop Python

You’re incrementing count in the inner loop which is why you keep getting larger numbers before you want to

You could just do this.

>>> for i in range(1, 10):
        print str(i) * i


1
22
333
4444
55555
666666
7777777
88888888
999999999

or if you want the nested loop for some reason

from __future__ import print_function

for i in range(1, 10):
    for j in range(i):
        print(i, end='')
    print()

Leave a Comment