Python Program:

- To print sideway triangle pattern using numbers

Example:

User Input: 3

Output:

A
A B
A B C
A B
A
columns=int(input("Enter number of columns : "))
trows=2*columns-1
k=1
for i in range(1,trows+1):
  c=65
  for j in range(1,k+1):
    print(chr(c), end=" ")
    c+=1
  if(i<columns):
    k+=1
  else:
    k-=1
  print("")

Output:

Enter number of columns: 4

A
A B
A B C
A B C D
A B C
A B
A
Program
pattern

Main Logic :

trows=2*columns-1   # trows : total rows to print
k=1;  # Used to trigger decreasing order of number

for i in range(1,trows+1):
  c=65
  for j in range(1,k+1):
    print(chr(c), end=" ")
    c+=1
  #check for position change at which triangle number value to decrease
  if(i<columns):
    k+=1
  else:
    k-=1
  print("")

You can print the same pattern in small alphabets, just set c=97

Concept

Coming Soon !

Quick
Tutorial

Quote

Make bold choices and make mistakes. It’s all those things that add up to the person you become.