Given a number N write a program to print a triangular pattern of N lines with the number as shown below
1
121
12321
1234321
Expert's answer
N = int(input())
w = len(str(N))
for i inrange(N):
nums = [" "*(w-len(str(j)))+str(j) for j inrange(1,i+2)]
nums += nums[-2::-1]
s = " "*(w*(N-i-1)) + "".join(nums)
print(s)
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot