+ 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
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: "))
+ 5
Love its corrected.
+ 5
Didn't get you. What do you mean by each entry?
+ 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.
0
value [i]=[]
displays
IndexError: list assignment index out of range
0
Thanks. How do I count each entry though?
Example
enter[0][0]:
enter[0][1]:
enter[0][2]:
enter[1][0]:
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]
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]: