CJCoding With Joseph
15free / daySign inCreate account

Right Aligned Triangle

Read a height n and print a triangle of stars that leans on the right edge: row k (counting from 1) has n - k spaces and then k stars, so the last row is n stars with no spaces. Use nested while loops, printing spaces and stars with end='' and ending each row with a bare print(); do not build strings with multiplication. Input: one integer of at least 1, no prompt.

Expected Output:

  *
 **
***

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

Hints3 available
Topics:
Loops
📥 Auto-Input:
3\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.