๐Ÿ PyQuest๐Ÿ•น๏ธ Challenge Arcade ยท ๐Ÿ”บ Pyramid Printer
โญ 0 XP๐Ÿ Python is waking upโ€ฆ

Pyramid Printer ๐Ÿ”บ

Final boss. ๐Ÿ‘‘

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

That's pyramid(4). Look very closely at row 3 of 4: it has 2 spaces in front and 5 stars. Row 4 has 1 space... no wait, 0 spaces and 7 stars.

See the pattern? For a pyramid of n rows, on row i:

  • spaces in front = n - i
  • stars = i * 2 - 1

Check it: row 1 of 4 โžœ 3 spaces, 1 star. Row 4 of 4 โžœ 0 spaces, 7 stars. It works! ๐ŸŽฏ

Build the line with repetition and glue it together:

line = " " * 3 + "*" * 1
print(line)

Your mission

Write a function called pyramid(n) that prints an n-row star pyramid, centred with spaces.

This one prints instead of returning โ€” I'll call pyramid(4) and pyramid(3) and count your stars and spaces. Make it work for any n, not just one. ๐Ÿ—๏ธ

Your code

Press โ–ถ Run to see what your code does!