dimanche 22 avril 2018

alternate solution for printing pattern using python

I want to print pattern using python and i have done it but i want to know other solutions possible for the same:-

A B C D E F G F E D C B A
A B C D E F   F E D C B A
A B C D E       E D C B A
......
....
A                       A

and here is my code:-

    n=0
for i in range(71,64,-1):
    for j in range(65,i+1):
        a=chr(j)
        print(a, end=" ")
    if n>0:
        for l in range(1,3+(n-1)*4):
            print(end=" ")
    if i<71:
        j=j+1
    for k in range(j-1,64,-1):
        b=chr(k)
        print(b, end=" ")
    n=n+1
    print()

Aucun commentaire:

Enregistrer un commentaire