Patterns
Read · 1 of 3
Let the row decide
For a triangle, row i has i stars, so the inner loop goes up to i instead of a fixed number.
"*".repeat(i) builds i stars in one go, handy once you understand the loop version.
1*2**3***
Read · 1 of 3
For a triangle, row i has i stars, so the inner loop goes up to i instead of a fixed number.
"*".repeat(i) builds i stars in one go, handy once you understand the loop version.
1*2**3***