I have users inputting into my program the degree of a matrix (e.g 3x3 == X=3, Y=3) I then populate a list of 9 values that will make up my 3x3 matrix like so:
total = x * y # the x and y values inputted by the user
i = 1
while i <= total:
matrix.append(i)
i += 1
After I have this matrix populated I want to print it out such that I print values matrix[0], [1], [2] in the first row and so on. But I want to do this for any size matrix, I have tried this:
i = 1
j = 0
while j < total:
print matrix[j]
if not i == x:
print ''
i += 1
else:
print '\n'
i = 1
j += 1
With no luck as it prints each value on a new line regardless... Any help is appreciated, thanks!