KnowledgeBoat Logo

Computer Science

Write programs using nested loops to produce the following patterns:

A
B B
C C C
D D D D
E E E E E

Python

Python Control Flow

28 Likes

Answer

n = 5
t = 65

for i in range(n) :
    for j in range(i + 1) :
        print(chr(t), end = ' ')
    t += 1
    print()

Output

A 
B B 
C C C
D D D D
E E E E E

Answered By

8 Likes


Related Questions