Python: How to Write Logic to Print Triangle

The below is the best example for nested loop in Python language. The specialty of this logic is you can create your output in the form of triangle. Logic in Python max = 8 for x in range(1, max + 1): for y in range(1, x + 1): print y, print Result 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