Skip to content
CampusEduX

Star Pyramid Pattern

Mediumpython
Learn the Concept: Loops

Print a centered pyramid of stars with the given number of rows, using nested loops.

Example for 4 rows:

   *
  ***
 *****
*******

Approach: for row i (starting at 1), print (rows - i) leading spaces followed by (2*i - 1) stars.

Input: One line: the number of rows (a whole number).

Output: rows lines forming a centered star pyramid, as shown above.

Related Problems

Input (stdin)

Output

Run your code to see output here...