Python Program To Print A-BB-CCC-DDDD Pattern Up To n Lines


This Python program prints or generates A-BB-CCC-DDDD upto n lines given by user.


In this program %c is used for displaying corresponding ASCII character of a number. For example to display ASCII character corresponding to 65; print("%c" %(65)) which gives A as output.

Python Source Code: A-BB-CCC Pattern


# A-BB-CCC-DDDD Pattern up to n lines

n = int(input("Enter number of rows: "))

a = 65

for i in range(1,n+1):

    for j in range(1, i+1):
        print("%c" %(a), end="")
    a +=1
    print()

Output

Enter number of rows: 10
A
BB
CCC
DDDD
EEEEE
FFFFFF
GGGGGGG
HHHHHHHH
IIIIIIIII
JJJJJJJJJJ