In this problem we are going to print right half star pattern
*
* *
* * *
* * * *
* * * * *
Code :
# Python program to print right half pyramid star pattern
def StarPyramid(n):
for i in range(n):
for j in range(n-i-1):
print(" ", end = " ")
for j in range(i+1):
print("*", end = " ")
print()
n = int(input("Enter Number of Rows : "))
StarPyramid(n)
Output :
Enter Number of Rows : 6
*
* *
* * *
* * * *
* * * * *
* * * * * *
Explanation :
In this program we have to create nested for loop. For loop with the initiator is used for rows and with j's is used to print columns (space and star)
0 Comments
Ask Your Queries in the comments