Create Square Shape with Number Pattern #1 in Python

thumbnail

In this tutorial, you learn to create square shape with number pattern #1 in python. The program is show as follows.

# Created by inpows
# Visit inpows.com for more python tutorials

n = int(input("Enter number: "))
for i in range(1,n+1):
    for j in range(n,0,-1):
        if(j>=i):
            print(n-j+i,end="")
        else:
            print(j,end="")
    print("")

The output will be show as follows.

# Output 1
Enter number: 5
12345
23451
34521
45321
54321

# Output 2
Enter number: 7
1234567
2345671
3456721
4567321
5674321
6754321
7654321
Back To Top