CJCoding With Joseph
15free / daySign inCreate account

Diamond Of Stars

Read a number n and print a diamond of stars: the top half has rows of 1, 3, 5, ... up to 2 * n - 1 stars (n rows), and the bottom half mirrors it back down to 1 star, giving 2n - 1 rows in total. Every row is centred by leading spaces so the widest row has none and each row one step away from the middle has one more space. Use nested while loops printing spaces and stars with end='' and a bare print() at the end of each row; do not multiply strings. Input: one integer of at least 1, no prompt. An input of 1 prints a single star.

Expected Output:

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

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
LoopsPractice Problems
📥 Auto-Input:
4\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.