- To print half triangle pattern using alphabet
User Input: 3
Output:
A A B A B C
rows=int(input("Enter number of rows : "))
for i in range(1,rows+1):
c=65
for j in range(1,i+1):
print(chr(c),end=" ")
c+=1
print("")
Enter number of rows : 4 A A B A B C A B C DProgram
Main logic :
for i in range(1,rows+1): #rows : number of rows to print
c=65 #"A" starts from 65
for j in range(1,i+1):
print(chr(c),end=" ")
c+=1
print("")
You can print the same pattern in small alphabets, just set c=97