Hollow Full Pyramid-1

Here is my code:
By using this below code i’m getting stars in two sides, one side is missing:
I need help in this:

Please review the screenshot I have attached.

n=int(input())
for row in range(n):
    for col in range(n):
        if row==n-1 or col+row==n-1 :
            print("*",end=" ")
        else:
            print(" ", end="")
    print()

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

If the first is the condition for the bottom side, and the second for the left side - you don’t have a condition for the right side! What should that condition be?

Yes, my question is also same,

can you help me with this

need help to form third line which contains stars . screenshot attached

Yes, you need to figure out the condition

if for the left side it is row+column == n-1 and for bottom it is row == n-1, you need to figure out the condition for right hand side.

What are the coordinates of each of those stars? What are the values of row and column when you want those stars to appear?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.