shri harshan
shri harshan

Reputation: 1

print python pattern for given value of N

Example input: 7

Output:

ABCDEFGGFEDCBA
ABCDEF  FEDCBA
ABCDE    EDCBA
ABCD      DCBA
ABC        CBA
AB          BA
A            A

Code:

a = int(input())
for i in range(a):
    p = 65
    for j in range(i, a):
        print(chr(p), end="")
        p+=1
    print()

I don't know what to do next.

Upvotes: 0

Views: 257

Answers (1)

ILee
ILee

Reputation: 33

Please check the following codes

a = int(input())
for i in range(a):
    p = 65
    for j in range(i, a):
        print(chr(p),end="")
        p += 1

    for z in range(0, i*2):
        print(" ", end="")

    for k in range(a, i, -1):
        p -= 1
        print(chr(p), end="")

    print()

Upvotes: 2

Related Questions