Python Program:

- To print sideway triangle pattern using *

Example:

User Input: 3

Output:

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

Output:

Enter number of columns: 4

*
* *
* * *
* * * *
* * *
* *
*
Program
pattern

Main Logic :

trows=2*columns-1  #trows : total rows to print
k=1   #Used to trigger decreasing order of *
for i in range(1,trows+1):
  for j in range(1,k+1):
    print("* ", end="")
  #Check for position change at which triangle * value to decrease
  if(i<columns):
    k+=1
  else:
    k-=1
  print("")

You can print any thing in this pattern, just replace your value with *

Concept

Coming Soon !

Quick
Tutorial

Quote

Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning.