← Back to Loops
Question 396
Right Aligned Triangle
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
Sign in to use hintsTopics:
Loops
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.