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.

What do you mean?
I can't exactly understand what you are trying to do...

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?

info: variable values

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 + '+'
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.