Challenge: Star Pyramid

Lab Python Intermediate 20 points

Read a height h and print a pyramid of stars. For h = 3:

  *
 ***
*****

Input

One whole number, the height (1 or more).

Output

h lines. Row r (starting at 1) has h - r spaces and then 2*r - 1 stars.

Example

Input

3

Output

  *
 ***
*****
Sample input available Sample output available
Editor
Python

Hints

Loop r from 1 to h.

" " * 2 gives two spaces, "*" * 3 gives three stars.

Don't print spaces after the stars.

Solution explanation

Each row is some spaces followed by some stars. Work out the two numbers from the row number.

Show solution
h = int(input())
for r in range(1, h + 1):
    print(" " * (h - r) + "*" * (2 * r - 1))
Output
Answer
HOME LEARN COMMUNITY DASHBOARD