Write a function that takes a 2D list(matrix) of 3x3 and ask user to input the values
def input_values(matrix):
for i in range(len(matrix)):
k = 0
while k < len(matrix[i]):
tmp = input('M[{}][{}] = '.format(i+1,k+1))
try:
matrix[i][k] = int(tmp)
k += 1
except ValueError:
print('incorrect input')
continue
return matrix
Comments
Leave a comment