A B C D E D C B A
A B C D D C B A
A B C C B A
A B B A
A A
make this pattern using the code below:
n = int(input('\nEnter the No. of rows : '))
n=n//2+1
print('\n')
# this is a never ending loop
r=n
i=-1
s=chr(64+1)
while r>=n:
c=j=1
while c<=n*2-1:
print(s if c<=r else ' ',end='')
if c==n: j=-1
c=c+j
print()
if r==1: i=1
r=r+i
if i==1 and r>n:
break
previously i also made and succeded in making hollow diamond inscribed in rectangle so here it is:
n = int(input('\nEnter the No. of rows : '))
n=n//2+1
print('\n')
r=n
i=-1
while r<=n:
c=j=1
while c>=1:
print('*' if c<=r else ' ',end='')
if c==n: j=-1
c=c+j
print()
if r==1: i=1
r=r+i
print()
i have tried many ways but the code isnt working. i only want in this format so please understand and edit the code
i was expecting this:
A B C D E D C B A
A B C D D C B A
A B C C B A
A B B A
A A
but i am unable to make this.
Aucun commentaire:
Enregistrer un commentaire