Create a Square Shape with Number Pattern #2 in Python

thumbnail

In this tutorial, you will create a square shape with number pattern #2 in python. You don’t need to import any library. The code is show as follow.

# 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(i,n+i):
        print((j-1)%n+1,end="")
    print("")
# Output 1
Enter number: 5
12345
23451
34512
45123
51234

# Output 2
Enter number: 7
1234567
2345671
3456712
4567123
5671234
6712345
7123456
Back To Top