The below is the best example for Nested Loop in Python. With this you can create triangle. max = 8 for x in range(1,max+1): for y in range(1,x+1): print y, print The output is as follows 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6 1 2 3 4 5 6 7 1 2 3 4 5 6 7 8 Also Read Python while loop Python for loop example