Python Program:

- To print sideway reverse triangle pattern using *

Example:

User Input: 3

Output:

    *
  * *
* * *
  * *
    *
columns=int(input("Enter number of columns : "))
k=trows=2*columns-1
for i in range(trows,0,-1):
  for j in range(1,trows+1):
    if(j<k):
      print("  ", end="")
    else:
      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=trows   #Used to trigger decreasing order of *
for i in range(trows,0,-1):
  for j in range(1,trows+1):
    if(j<k):
      print("  ", end="")
    else:
      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.