Answer to Question #346961 in Python for Som

Question #346961

Given a number N, write a program to print a triangular pattern of N lines with numbers as shown below.


Input

The input will be a single line containing a positive integer (N).

Output

The output should be N rows with numbers.

For example: If the given number is 4 --

1

121

12321

1234321


If given number is 7 --

1

121

12321

1234321

123454321

12345654321

1234567654321


Note: In left hand side there will be no gap ,it should look like Right Triangle.

1
Expert's answer
2022-05-31T16:10:42-0400
N = int(input("Enter N: "))
for i in range(1, N + 1):
    for j in range(1, i + 1):
        print(j, end="")
    for j in range(i - 1, 0, -1):
        print(j, end="")
    print()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS