I am working on a program that prints out steps and running into a strange problem with a while loop. For some reason the loop starts at 1 instead of 0 and I can't pinpoint why it is exactly.
Current Output:
Array Rows: 5
Array Columns: 5
_ _ _ _ _
X _ _ _ _
X X _ _ _
X X X _ _
X X X X _
Desired Output:
Array Rows: 5
Array Columns: 5
X _ _ _ _
X X _ _ _
X X X _ _
X X X X _
X X X X X
Code For Function:
if(rows == columns):
x = 0
while(x < rows):
y = 0
while(y < x):
array[x][y] = "X"
y += 1
x += 1
Note: The rows and columns are user inputs from the main program to specify how large the 2D list should be.
Here is the output with a debugging print showing the issue:
Array Rows: 5
Array Columns: 5
1
2
2
3
3
3
4
4
4
4
_ _ _ _ _
X _ _ _ _
X X _ _ _
X X X _ _
X X X X _
Note: The change in this output is a print statement of "x" in the 2nd nested while loop.
Any help would be greatly appreciated as I've spent a ton of time trying to figure out what is wrong without any luck :/