Yes, many patterns (like pyramids) require one inner loop to print blank spaces, followed by a second inner loop to print the stars.
Understanding Row and Column Relationships in Patterns
Can a pattern require two inner loops?
The answer
More FAQs in Understanding Row and Column Relationships in Patterns
It always consists of an outer loop tracking the rows, one or more inner loops tracking columns/spaces, and a newline command at the end of the outer loop.
Create a table on paper. Write down the row number on the left, and the number of stars on the right. Look for a linear equation (y = mx + b) that connects them.
You are likely using a print-line command (like println) inside the inner loop, forcing every single star onto a new line instead of keeping them on the same row.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.