+ 1

Matrix Python

How do you use a loop for users input in a matrix format? enter value[0][0] : enter value[0][1] : enter value[0][2] : and so on

18th Mar 2019, 4:41 AM
Love
Love - avatar
8 Respostas
+ 5
Do you mean two nested for loops? Edit: corrected value=[] for i in range(5): value.append([]) for j in range(5): value[i].append(input("Enter: "))
18th Mar 2019, 4:55 AM
Шащи Ранжан
Шащи Ранжан - avatar
+ 5
Love its corrected.
18th Mar 2019, 3:24 PM
Шащи Ранжан
Шащи Ранжан - avatar
+ 5
Didn't get you. What do you mean by each entry?
18th Mar 2019, 3:35 PM
Шащи Ранжан
Шащи Ранжан - avatar
+ 4
Love we already have user prompt in there. Do you want to count how many prompts are there? It's just the number in the range. Your doubt is still unclear.
18th Mar 2019, 3:56 PM
Шащи Ранжан
Шащи Ранжан - avatar
0
value [i]=[] displays IndexError: list assignment index out of range
18th Mar 2019, 3:09 PM
Love
Love - avatar
0
Thanks. How do I count each entry though? Example enter[0][0]: enter[0][1]: enter[0][2]: enter[1][0]:
18th Mar 2019, 3:32 PM
Love
Love - avatar
0
I mean the user prompt. So counting through each entry while displaying it to the user so user prompt would be Enter[0][0]: Enter[0][1]: Enter[0][2]
18th Mar 2019, 3:44 PM
Love
Love - avatar
0
I want to count through the matrix and display the index of each prompt So instead of just enter, the user sees Enter [0][0]: Enter[0][1]: Enter[0][2]: Enter[1][0]:
18th Mar 2019, 4:02 PM
Love
Love - avatar