Python Program to Print a-bb-ccc-dddd Pattern up To n Lines


This program prints (generates) a-bb-ccc-dddd pattern up to n lines given by user in Python programming language.


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-dddd Pattern


# a-bb-ccc-dddd Pattern up to n lines

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

a = 97

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