Star Pyramid
Completed
Read n and print a centred pyramid of stars with n rows. Row i (from 1) has n−i spaces then 2i−1 stars.
Input
One integer.
Output
n rows.
Example
Input
4
Output
* *** ***** *******
Editor
Python
Hints
Work out the number of spaces and stars for each row, then use string repetition.
Solution explanation
Pattern problems are about finding a formula for each row.
Show solution
n = int(input())
for i in range(1, n + 1):
print(" " * (n - i) + "*" * (2 * i - 1))