Making user to input his own matrix

what is the problem her I want the user to input his own matrix

The row is being appended to the columns after every matrix element. Deindent q.append

1 Like

Sorry, but I didn’t understand
how to make the rows and columns not appended with each other

The line q.append(z) is indented too much; it’s inside the inner for loop.

1 Like

Hey, so a much better way to share code is instead of posting a screenshot, copy and paste your code directly inside triple backquotes:

print('Like this!')

This way, we can copy and paste this code to edit it instead of having to re-type everything out ourselves. Helpers are helping us for free, so we need to make it as easy for them to help us as possible.

I can answer your question, but I have to re-type (some of) your code:

for i in range(rows):
    z = []
    for j in range(columns):
        c=int(input())
        z.append(c)
        q.append(z)

As Matthew Barnett pointed out, you want to remove the indentation from the q.append(z) line:

for i in range(rows):
    z = []
    for j in range(columns):
        c=int(input())
        z.append(c)
    q.append(z)