jeudi 18 juin 2020

Printing pattern without importing modules

Please help me print the pattern below as it is, if the input entered is 7:

1 1 1 1 1 1 1
1 2 2 2 2 2 1
1 2 3 3 3 2 1
1 2 3 4 3 2 1
1 2 3 3 3 2 1
1 2 2 2 2 2 1
1 1 1 1 1 1 1

I figured out to find the middle element of the pattern with any input:

rows=int(input("Enter the number of rows:"))
l=[]
for x in range(1,rows+1):
    if x%2!=0:
        l.append(x)
mid_value=len(l)

Please help me complete the pattern...
Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire