num = int(input("Enter the Number: "))
for i in range(1, num+1):
for j in range(0, i):
print(" ", end="")
for j in range(1, (num*2 - (2*i - 1))+1):
if i == 1 or j == 1 or j ==(num*2 -(2*i-1)):
print("*", end="")
else:
print(" ", end="")
print()
Output
Enter the Number: 7
*************
* *
* *
* *
* *
* *
*
Process finished with exit code 0
n=int(input(‘Enter number:’))
for i in range(n):
for j in range(i):
print(‘ ‘,end=”)
for j in range(i,(2*n)-(i+1)):
if j==i or i==0 or j==(2*n)-(i+2):
print(‘*’,end=”)
else:
print(‘ ‘,end=”)
print()
n = int((input(“Enter the number:)))
for i in range(n,-1,-1):
if ((i==0) or (i==n)):
print(” “*(n-i)+ (“*”)*(2*i+1))
else:
print(” “*(n-i) + (“*”) + (” “)*(2*i -1) + (“*”))
TRY THIS BRO, IT’S WAY EASIER;
n = int(input(‘enter a number: ‘))
for i in range(n):
if i == 0:
print(‘*’*(n*2-1))
elif i == n-1:
print(‘ ‘*(n-1) + ‘*’)
else:
print(‘ ‘*i + ‘*’ + ‘ ‘*(2*(n-1-i)-1) + ‘*’)
Hey there, Kindly join our discord channel for all Technical queries. Our mentors are right there to help you with it.
n=int(input(‘Enter number:’))
for i in range(n):
for j in range(i):
print(‘ ‘,end=”)
for j in range(i,(2*n)-(i+1)):
if j==i or i==0 or j==(2*n)-(i+2):
print(‘*’,end=”)
else:
print(‘ ‘,end=”)
print()
# Inverted Hollow Pyramid Star Pattern Method – 2
n=int(input(“Enter the number: “))
for i in range(1,n+1):
for j in range(1,2*n):
# Condition of the if function
if(i==1 and j%2!=0) or i==j or i+j==n*2:
print(“*”,end=””)
else:
print(” “,end=””)
print()
n = int((input(“Enter the number:)))
for i in range(n,-1,-1):
if ((i==0) or (i==n)):
print(” “*(n-i)+ (“*”)*(2*i+1))
else:
print(” “*(n-i) + (“*”) + (” “)*(2*i -1) + (“*”))