from this starting point:

matrix = [[0 for x in range(5)] for y in range(3)]


I need to make this:

|0 0 0 0 0|
|0 0 0 0 0|
|0 0 0 0 0|
+-+-+-+-+-+
0 1 2 3 4

I have been trying .append and .replace to try and get the final result but nothing is going right.

I put in this in python >>>matrix = [[0 for x in range(5)] for y in range(3)]
>>>print matrix
and the result is:
[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]
I then, from that, want to make each of the 3 sections(rows) of [0, 0, 0, 0, 0] on a new line but remove [] and add | to the front and end and also add another line +-+-+-+-+-+ and also add the line 0 1 2 3 4 to make this:

|0 0 0 0 0|
|0 0 0 0 0|
|0 0 0 0 0|
+-+-+-+-+-+
0 1 2 3 4

such that >>>matrix[1][1]=1
>>>print matrix
will give: [[0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 0, 0]]
and then can be transformed into this with a function or something that is applied to matrix to give this:

|0 0 0 0 0|
|0 1 0 0 0|
|0 0 0 0 0|
+-+-+-+-+-+
0 1 2 3 4

print each element in for loop which is inside other loop to do the sides.Finish with bottom lines. Can you assume one number values or should you check for maximum length of numbers for the grid? If you must check, find max of len(str(numbers))) in each element and max of those.

i can't get the numbers to print out as 0 1 2 3 4, I'm getting:
0
1
2
3
4

How do i write for this?

Another way you could approach this ...

matrix = [[0 for x in range(5)] for y in range(3)]

for sublist in matrix:
    s = str(sublist)
    s = s.replace('[', '|').replace(']', '|').replace(',', "")
    print s

print '+-'*5 + '+'
This question has already been answered. Start a new discussion instead.