pattern in python

36

v = 1
lines = 4
for i in range(lines):
    for j in range(i):
        print(v, end=' ')
        v += 1
    print( )

numbers = 10
for rowIndex in range(numbers):
    rowString = ''
    for columnIndex in range(numbers): #Same number of points
        #each row is equivalent to the previous row + 1 - use existing iterator
        rowString += str(columnIndex + rowIndex) + '\t'
    print(rowString)

Comments

Submit
0 Comments