Half Pyramid - 4
Given an integer N as a starting number and K as input, write a program to print a number pyramid of K rows as shown below.
n = int(input('n: '))
k = int(input('k: '))
count = n
for i in range(k):
count += i+1
max_len = len(str(count))
for i in range(1, k+1):
s = ''
for j in range(i):
spases = max_len - len(str(n)) + 1
s += str(n) + ' '*spases
n += 1
print(s)
Comments
Leave a comment