John Dias John Dias - 1 month ago 9
Python Question

How do i print out a number triangle in python?

How do i print out a number triangle in python using a loop based program? It is not a homework assignment or anything its just an exercise from the book i have been trying to do but have not really come close. The triangle should print out looking like this:

1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6

Answer
for i in range(7):
    print (str(i) + " ")*i

output:

1  
2 2  
3 3 3  
4 4 4 4  
5 5 5 5 5  
6 6 6 6 6 6