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.
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()
Comments
Leave a comment